Python-based web framework used for rapid development of web applications.
The below command creates a new project named projectName
The below command starts the development server.
Django follows MVT(Model, View, Template) architecture.
The model represents the schema of the database.
View decides what data gets delivered to the template.
A sample .html file that contains HTML, CSS, and Javascript.
A python function that takes a web request and returns a web response.
Django's class-based views provide an object-oriented way of organizing your view code.
Set of URL patterns to be matched against the requested URL.
Similar to HTML forms but are created by Django using the form field.
Apps in Django are like independent modules for different functionalities.
To create an app, use the following command:
After creating an app, you need to list the app name in the INSTALLED_APPS
section of your settings.py
file:
Used to handle dynamic HTML files separately.
To configure templates in your settings.py
, you can use the following configuration:
A view is associated with every URL. This view is responsible for displaying the content from the template.
Migrations are Django's way of updating the database schema according to the changes that you make to your models.
To create a migration, use the following command:
This command is used to generate migration files with information on how to update the database schema, but it doesn't make changes to the actual database.
To apply the changes to the actual database, use the following command:
This command is used to execute the pending migrations and update the database schema according to the changes defined in the migration files.
Django comes with a ready-to-use admin interface.
To create an admin user, use the following command:
This command is used to create a superuser account with administrative privileges, allowing you to access and manage the Django admin interface.
Redirection is used to redirect the user to a specific page of the application on the occurrence of an event.