Django Notes
Django Notes
migrate will sync the database with the current state of any database models
contained
in the project and listed in INSTALLED_APPS. In other words, to make sure the
database
reflects the current state of your project you’ll need to run migrate (and also
makemigrations)
each time you update a model.
Django’s ORM will automatically turn this model into a database table for us.
whenever we create
or modify an existing model we’ll need to update Django in a two-step process:
1. First, we create a migrations file with the makemigrations command. Migration
files create
a reference of any changes to the database models which means we can track changes–
and
debug errors as necessary–over time.
2. Second, we build the actual database with the migrate command which executes the
instructions in our migrations file.
ADMIN
provides a visual way
to interact with data
where is our posts app? It’s not displayed on the main admin page!
Just as we must explicitly add new apps to the INSTALLED_APPS config, so, too, must
we update
an app’s admin.py file for it to appear in the admin.
STATIC
STATIC_URL: URL location of static files in our project
STATICFILES_DIR: we can tell Django where to look for static files beyond just
app/static folder