Root of the Django project is where manage.py resides
$ mkdir basic_django
$ cd basic_django
$ virtualenv
assume user already !pip install --user virtualenv$ virtualenv -p python3 .
$ source bin/activate
$ pip install django
$ deactivate
if you don't need virtualenv
$ django-admin
to see list of django commands$ mkdir ./src && cd ./src
$ django-admin startproject <your project name> .
$ python manage.py runserver
BASE_DIR
= project locationALLOWED_HOSTS
= list of urls that can access django projectINSTALLED_APPS
= installed components for particular django projectMIDDLEWARE
= tell us how requests/security are handledROOT_URLCONF
= tell us how urls are routingTEMPLATES
= tell us how html pages should be renderedWSGI_APPLICATION
= tell us how server worksDATABASES
= databases mappingAUTH_PASSWORD_VALIDATORS
= password's standardsSTATIS_URL
= tell us where do we store static files$ python manage.py migrate
to Sync changes in settings
- django has built-in apps. We also can install third-party apps.
$ python manage.py migrate
to Sync changes in settings including auth, admin apps$ python manage.py createsuperuser
create the ultimate user$ python manage.py startapp <your appp name>
create apps- you may edit your newly created apps, you may also need to update apps in
INSTALLED_APPS
$ python manage.py makemigrations
Update what are we migrating$ python manage.py migrate
actually sync settings- Also register your models in the relative admin.py
admin.site.register(Product)
$python manage.py shell
work with django project in (kind of) python shell