Free · 55 Topics · No Signup
Django Notes
Python web framework — models, templates, QuerySets, PostgreSQL and deployment — written by CodingNow 2.0's mentors. Free to read, structured to actually help you learn.
Django notes by CodingNow 2.0 cover 55 topics — from django home to add bootstrap 5 — each explained with short definitions, syntax and runnable code examples. They are 100% free, need no signup, and work as quick revision for college exams, Django interviews and CodingNow 2.0's mentor-led Django course in Pitampura, Delhi.
No notes found. Try a different search term, or browse all Django notes.
Django Tutorial
15 of 15 topics publishedDjango Home
Django is a back-end server side web framework.
Django Intro
Django is a Python framework that makes it easier to create web sites using Python.
Django Get Started
Note: To install Django, you must have Python installed, and a package manager like PIP. PIP is included in Python from version 3.4.
Create Virtual Environment
It is suggested to have a dedicated virtual environment for each Django project, and one way to manage a virtual environment is venv, which is included in Pytho
Install Django
Now, that we have created a virtual environment, we are ready to install Django.
Django Create Project
Once you have come up with a suitable name for your Django project, like mine: my_tennis_club , navigate to where in the file system you want to store the code
Django Create App
An app is a web application that has a specific meaning in your project, like a home page, a contact form, or a members database.
Django Views
Django views are Python functions that take http requests and return http response, like HTML documents.
Django URLs
Create a file named urls.py in the same folder as the views.py file, and type this code in it:
Django Templates
In the Django Intro page, we learned that the result should be in HTML, and it should be created in a template, so let's do that.
Django Models
A Django model is a table in your database.
Django Insert Data
The Members table created in the previous chapter is empty.
Django Update Data
To update records that are already in the database, we first have to get the record we want to update:
Django Delete Data
To delete a record in a table, start by getting the record you want to delete:
Django Update Model
To add a field to a table after it is created, open the models.py file, and make your changes:
Display Data
6 of 6 topics publishedPrep Template and View
After creating Models, with the fields and data we want in them, it is time to display the data in a web page.
Add Link to Details
The next step in our web page will be to add a Details page, where we can list more details about a specific member.
Add Master Template
In the previous pages we created two templates, one for listing all members, and one for details about a member.
Add Main Index Page
The main page will be the landing page when someone visits the root folder of the project.
Django 404 Template
If you try to access a page that does not exist (a 404 error), Django directs you to a built-in view that handles 404 errors.
Add Test View
When testing different aspects of Django, it can be a good idea to have somewhere to test code without destroying the main project.
Admin
7 of 7 topics publishedDjango Admin
Django Admin is a really great tool in Django, it is actually a CRUD user interface of all your models!
Create User
To be able to log into the admin application, we need to create a user.
Include Models
To include the Member model in the admin interface, we have to tell Django that this model should be visible in the admin interface.
Set List Display
Make the List Display More Reader-Friendly
Update Members
Now we are able to create, update, and delete members in our database, and we start by giving them all a date for when they became members.
Add Members
To add a new member, click on the "ADD MEMBER" button in the top right corner:
Delete Members
To delete a new member, you can either select a member and choose the action "Delete selected members" like this:
Django Syntax
6 of 6 topics publishedDjango Variables
In Django templates, you can render variables by putting them inside {{ }} brackets:
Django Tags
In Django templates, you can perform programming logic like executing if statements and for loops.
Django If Else
An if statement evaluates a variable and executes a block of code if the value is true.
Django For Loop
A for loop is used for iterating over a sequence, like looping over items in an array, a list, or a dictionary.
Django Comment
Comments allows you to have sections of code that should be ignored.
Django Include
The include tag allows you to include a template inside the current template.
QuerySets
4 of 4 topics publishedQuerySet Introduction
A QuerySet is a collection of data from a database.
QuerySet Get
There are different methods to get data from a model into a QuerySet.
QuerySet Filter
The filter() method is used to filter your search, and allows you to return only the rows that matches the search term.
QuerySet Order By
To sort QuerySets, Django uses the order_by() method:
Static Files
5 of 5 topics publishedAdd Static Files
When building web applications, you probably want to add some static files like images or css files.
Install WhiteNoise
Django does not have a built-in solution for serving static files, at least not in production when DEBUG has to be False .
Collect Static Files
Static files in your project, like stylesheets, JavaScripts, and images, are not handled automatically by Django when DEBUG = False .
Add Global Static Files
We have learned how to add a static file in the application's static folder, and how to use it in the application.
Add Styles to the Project
If you have followed the steps in the entire Django tutorial, you will have a my_tennis_club project on your computer, with 5 members:
PostgreSQL
4 of 4 topics publishedPostgreSQL Intro
Django comes with a SQLite database which is great for testing and debugging at the beginning of a project.
Create Database in RDS
Inside the RDS service, create a database, either by navigating to the Database section, or just click the "Create database" button:
Connect to Database
To make Django able to connect to your database, you have to specify it in the DATABASES tuple in the settings.py file.
Add Members
The "My Tennis Club" project has no members: 127.0.0.1:8000/ .
Deploy Django
6 of 6 topics publishedElastic Beanstalk (EB)
To deploy a project means to make it visible for other people on the internet.
Create requirements.txt
When you create a Django application, there are some Python packages that your project depends on.
Create django.config
We have chosen AWS as our hosting provider, and Elastic Beanstalk as a service to deploy the Django project, and it has some specific requirements.
Create .zip File
To wrap your project into a .zip file, you cannot zip the entire project folder, but choose the files and folders manually.
Deploy with EB
In AWS, navigate to the Elastic Beanstalk application, as we did in the Choose Provider chapter, and click the "Create application" button:
Update Project
Any changes you do with the application locally, on your own computer, is not visible on the deployed version.
More Django
2 of 2 topics publishedReady to go from notes to a real career?
Join CodingNow 2.0's Django course — live mentorship, hands-on projects, and 100% placement support in Delhi NCR.
Enroll Now — Free Demo AvailableDjango Notes – FAQs
What students search before reading Django notes.