Home

Search IconIcon to open search

Django quick tips

Start a project:

1
2
3
4
poetry new
poetry shell
poetry add Django
django-admin startproject my-project .

Create an app:

1
python manage.py startapp my-app

Run local server:

1
python manage.py runserver

Migrations:

1
2
python manage.py makemigrations
python manage.py migrate

To change your models, you have to makemigrations, than migrate.

Reset all the mess in migrations:

1
2
3
4
5
find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete
rm db.sqlite3
python manage.py makemigrations
python manage.py migrate