Getting started with Django - Basic application
- Download and install Python, if not installed.
- Install django python package
pip install Django
- Create application
django-admin startproject mysite
- Migrate the pre-installed apps to use them with your project
python manage.py migrate
- Create admin user
python manage.py createsuperuser
- Run the application. If port is not specified, default is 8000
python manage.py runserver 8080
- Access the admin application in browser http://127.0.0.1:8080/admin/
- Access the basic application in browser http://127.0.0.1:8080/polls/
- Create new app polls inside base app
python manage.py startapp polls
- Generate the model SQLs before migrate
python manage.py sqlmigrate polls 0001
- Migrate the change to use
python manage.py migrate
- After changing models(in models.py) migrate those changes
python manage.py makemigrations
- Apply model changes to the database
python manage.py migrate
- Test the polls app
python manage.py test polls