Boilerplate: Make A Basic Django App With The Ability To Create, Read, Update, and Delete Content From A Protected Web Interface
Introduction
-
These are my notes for how to set up a basic model and views for a single Notes list.
-
This assumes you've gone though: Boilerplate: Create A New Django Site/Project , Boilerplate: Add Basic Template And Static File Handling In Django , and Boilerplate: Add Basic User Authencation To A Django Site
link -
Login is required for creating, editing, and deleting notes
-
This uses server side for confirmation of delete. Could switch this to using javascript on the client-site, but the server side should still be there as the final authority
Boilerplate Steps
-
Make sure you've started the Python venv and are in the directory with: manage.py
TODO: Write up how to make sure you're in the proper venv
-
Create the app
terminal commands -
Make the templates directory:
terminal commands -
The
=
section ofsite_files/settings.py to add:python,
It should look like this when you're done:
site_files/settings.py - replacement lines -
Update the top level urls patterns
site_files/urls.py - full content replacement -
Create the Note model
notes/models.py - full content replacement -
Make the "notes/urls.py" file:
create new file: notes/urls.py -
Add the admin for the notes page
notes/admin.py - full content replacement -
Add the functions to:
notes/views.py notes/views.py - full content replacement -
Add the forms.py file:
notes/forms.py - new file to create -
Create the
index.html templatenotes/templates/notes/index.html - new file to create -
Create the
view.html templatenotes/templates/notes/view.html - new file to create -
Create the
create.html templatenotes/templates/notes/create.html - new file content -
Create the
edit.html templatenotes/templates/notes/edit.html - new file content -
Create the
delete.html templatenotes/templates/notes/delete.html - new file content -
Run the migrations
terminal commands -
Start the server:
terminal commands -
Visit the page:
link