Creating the first project using Django
Django Architecture Diagram
For more information regarding the architecture of Django Framework, watch the youtube video https://youtu.be/fGk5ewTUOIo
Command to start a project using Django
django-admin startproject <project_name>
After executing the above command a project folder will be created with the name project_name
You can have a look at the project directory structure
Command to start an application in a project
python manage.py startapp <app_name>
Open settings.py which is in the sub project folder of the project
For example, as I have created the project named mystore, another sub folder named mystore is created.
In settings.py file add the app ‘app_name’
For example: Here it is ‘garments’
Commands to make migrations
python manage.py makemigrations <app_name>
Ex: here the app is garments
python manage.py migrate
Command to run the server
python manage.py runserver
Go to http://127.0.0.1:8000
You can find a page like the below.
Open models.py which is in the <application> folder.
For Example here it is garments
Create appropriate fields according to your webpage requirement in models.py
Now you should register the models in admin.py which is in the same <application> folder.
The command to register the application is
admin.site.register(<class_name>)
Create a super user by using the following command
python manage.py createsuperuser
To convert the models to tables use the following command
python manage.py makemigrations <application>
For Example here the application name is garments
so the command is
python manage.py make migrations garments
To create the tables in sqlite batabase use the following command
python manage.py migrate
To run the server use the following command
python manage.py runserver
Click on the url(http://127.0.0.1:8000) and append /admin (http://127.0.0.1:8000/admin)
Use the above created login credentials created using the command createsuperuser
Use can see the admin panel with the name of the application and class created by you previously.
Click on the class name (here it is shirts)
You can add more elements by clicking on add shirt and finally click the save button to save it
Then you can see the object which you have created just now.
Open the database and you can see that the values entered by you in the admin panel are stored in the database.













