Django Basic Commands while developing Application

Wednesday, July 25, 2018 0 Comments A+ a-


1) Go to: /var/www/html/django-apps (Your project directory) 

2) Activate virtual environment:  
.  env/bin/activate

3) TO create tables at backend(First time):
python manage.py migrate                 

4) To Run server:
 python manage.py runserver 10.0.1.89:8000     

5) TO create admin user in Django application: 
python manage.py createsuperuser      

6) TO create new app in Django:
django-admin startapp boards

7) To generate SQL Queries in boards/migrations/0001_initial.py file :
python manage.py makemigrations

8) Above SQL Queries will execute in database:
python manage.py sqlmigrate boards 0001

9) The next step now is to apply the migration we generated to the database:
python manage.py migrate

10) TO create new app in project:
django-admin startapp accounts

11) If you get error like Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Run below commands:
python manage.py makemigrations
python manage.py migrate
python manage.py sqlmigrate boards 0001

Blogger, Software Techie, Programmer