1.6 KiB
1.6 KiB
title | sidebar | showTitle | hideAnchor |
---|---|---|---|
Our Notes On Django | Handbook | true | true |
Start here
If, like me, you haven't worked with Django before, the best place to start with is Writing your first Django app from the official Django website. This gives you a quick understanding of the major parts of Django without needing to read an entire book to get it.
Useful Django commands
django-admin startproject mysite
- creates Django projectpython manage.py runserver
- starts Django web server (optionally add a port at the end8080
)python manage.py startapp polls
- creates Django app in projectpython manage.py makemigrations polls
- creates migration scripts in migrations folderpython manage.py sqlmigrate polls 0001
- shows SQL that will run for this migration but doesn't perform itpython manage.py migrate
- performs all migrationspython manage.py shell
- puts you in a Django ORM shell to play with the models on the command-linepython manage.py createsuperuser
- creates super user for django admin app which comes by default with all Django projects, url/admin
python manage.py test polls
- run tests for polls app
Useful resources
- Writing your first Django app. I recommend reading Parts 1-5 of the 7 parts, skip 6+ since they are not relevant to PostHog. We do use Django built-in testing so part 5 is required reading.
- Two Scoops of Django (e-book)