0% found this document useful (0 votes)
2 views

Django Notes

The document outlines the steps to create a Django project and app, including commands for starting the project and app, as well as explanations of key files such as manage.py, wsgi.py, urls.py, and settings.py. It emphasizes the importance of configuring the app in settings.py and provides guidance on URL routing and using templates for HTML pages. Additionally, it includes instructions for launching and stopping the Django server.

Uploaded by

Niranjan Patil
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Django Notes

The document outlines the steps to create a Django project and app, including commands for starting the project and app, as well as explanations of key files such as manage.py, wsgi.py, urls.py, and settings.py. It emphasizes the importance of configuring the app in settings.py and provides guidance on URL routing and using templates for HTML pages. Additionally, it includes instructions for launching and stopping the Django server.

Uploaded by

Niranjan Patil
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Creating a project:

django-admin startproject ProjectName


django-admin startproject STM

Which files are what?


NOTE, currently all these files are related to project and not our app
1. Manage.py :
2. wsgi.py : Web server that django creats for us
3. urls.py : URL ROUTING SYSTEM FOR OUR WEB PORTAL which will consist the
list of paths
4. settings.py : Command center of our django app

Launching a Django App:


python manage.py runserver
this will take us to default landing page of our django app

Turning off the server


CTRL + C

So now we have created a project, but we are building our django app
Hence we have to create it

Creating our app


python manage.py startapp appName
python manage.py startapp SmartTrafficManager

Our app will be created with the appName with following files

1. admin.py - Admin panel


2. model.py - We build our database and Classbase Objects.
3. views.py - Functions and classes that triggers our url patterns

Now that our app is created we need to configure, i.e add our appname in installed
app of settings.py so that Django server will know that appName is connected with
our Project

ABOUT URL Paths:


Whenever we use some url path, like /object it triggers the function
associated with that urlpattern and return template or api or any response

NOTE: -> Always create functions in views.py and use the urls.py to
route to those functions.

Using Templates: Basically HTML pages

Create a folder names "templates" with exact same spelling, create a folder
with your appname and store the html pages in it

You might also like