Django Cheatsheet

Table of contents

Start project

$ django-admin startproject myproject  
$ cd myproject  
$ python3 manage.py startapp newapp  

Register newapp

$ vim myproject/myproject/settings.py  

Model sections

Url: https://docs.djangoproject.com/en/4.0/ref/models/

Register Models

$ vim admin.py # in your newapp dir  
from .models import Author, Genre, Book, BookInstance  
  
admin.site.register(Book)  
admin.site.register(Author)  
admin.site.register(Genre)  
admin.site.register(BookInstance)  

Create Superuser

$ python3 manage.py createsuperuser  

Migrate

$ python3 manage.py makemigrations  
$ python3 manage.py migrate  

Start dev server

$ python3 manage.py runserver  

Tutorial

Library tutorial