django demo
1.
$ django-admin startproject mysite
2.
$ python manage.py runserver
3.
$ python manage.py migrate
4.
$ python manage.py makemigrations polls
5.
$ python manage.py sqlmigrate polls 0001
6.
$ python manage.py migrate
Migrations are very powerful and let you change your models over time, as you develop your project, without the need to delete your database or tables and make new ones - it specializes in upgrading your database live, without losing data. We’ll cover them in more depth in a later part of the tutorial, but for now, remember the three-step guide to making model changes:
- Change your models (in
models.py
). - Run
python manage.py makemigrations
to create migrations for those changes - Run
python manage.py migrate
to apply those changes to the database.
The url()
function is passed four arguments, two required: regex
and view
, and two optional: kwargs
, and name
. At this point, it’s worth reviewing what these arguments are for.