official tutorials
log in sample
log in with AD account
multiple DB connection
-
Display README.md in VScode
Ctrl + Shift + V
-
Basic
django-admin startproject djg01 # initial project
python manage.py startapp polls # create new app (polls)
python manage.py createsuperuser # create admin
python manage.py runserver # run web service
- Play with database
python manage.py makemigrations polls # check changes of INSTALLED_APPS (polls) && generate a migration file
python manage.py sqlmigrate polls 0001 # display these changes (CREATE TABLE "polls_question" ("id" integer NOT NULL PRIMARY KEY AUTOINCRE......))
python manage.py migrate # operate with database based on the migration file
- Pre-install
pip install PyMySQL # for mysql
pip install psycopg2 # for PostgreSQL
- Decorator
@login_required(login_url="denglu:login" ) # , redirect_field_name="xxxx",
def al(request,username):
print(username)
return HttpResponse(username)