Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Initialize a New Project | Introduction to Django ORM
course content

Course Content

Django ORM Ninja: Advanced Techniques for Developers

Initialize a New ProjectInitialize a New Project

Let's begin a new project in your preferred IDE (such as PyCharm or VSCode) and name it, for instance, bookstore_orm.

Once you've set up your virtual environment, the next step is to install Django for this specific project using the following command:

To verify if Django is successfully installed and check its version, you can run:

Now, let's create a new Django project:

The dot at the end of the command indicates that we want to start our project in the current folder.

The new app package has been created and contains the necessary settings for our project. This module is responsible for connecting our application with the server: wsgi.py is responsible for the synchronous part of our application, and asgi.py is responsible for the asynchronous part. In urls.py, associations between URLs and their handlers are created.

Also, after running the 'startproject' command, you'll find a manage.py file in your root directory. This script is responsible for all operations with the database and the application in general.

Now, navigate to settings.py, and in the SECRET_KEY section, remember that it's essential for your application's security. Do not share it with anyone. For web applications deployed in production, it's recommended to store this information in a .env file along with other sensitive data.

Next, let's focus on the 'DATABASES' section. By default, Django uses SQLite3 as the database engine, which is sufficient for development purposes. However, for more professional applications, you might want to consider using PostgreSQL. For this project, we'll stick with the default database name and leave the other settings as they are.

Now, let's create a new application:

This command creates a new package called db in your project's root directory. We only need the migrations, init.py, models.py, and admin.py files from this new package.

Return to settings.py and add db to the 'INSTALLED_APPS' list.

With these steps, you have completed the setup of your ORM project.

Everything was clear?

Section 1. Chapter 4
course content

Course Content

Django ORM Ninja: Advanced Techniques for Developers

Initialize a New ProjectInitialize a New Project

Let's begin a new project in your preferred IDE (such as PyCharm or VSCode) and name it, for instance, bookstore_orm.

Once you've set up your virtual environment, the next step is to install Django for this specific project using the following command:

To verify if Django is successfully installed and check its version, you can run:

Now, let's create a new Django project:

The dot at the end of the command indicates that we want to start our project in the current folder.

The new app package has been created and contains the necessary settings for our project. This module is responsible for connecting our application with the server: wsgi.py is responsible for the synchronous part of our application, and asgi.py is responsible for the asynchronous part. In urls.py, associations between URLs and their handlers are created.

Also, after running the 'startproject' command, you'll find a manage.py file in your root directory. This script is responsible for all operations with the database and the application in general.

Now, navigate to settings.py, and in the SECRET_KEY section, remember that it's essential for your application's security. Do not share it with anyone. For web applications deployed in production, it's recommended to store this information in a .env file along with other sensitive data.

Next, let's focus on the 'DATABASES' section. By default, Django uses SQLite3 as the database engine, which is sufficient for development purposes. However, for more professional applications, you might want to consider using PostgreSQL. For this project, we'll stick with the default database name and leave the other settings as they are.

Now, let's create a new application:

This command creates a new package called db in your project's root directory. We only need the migrations, init.py, models.py, and admin.py files from this new package.

Return to settings.py and add db to the 'INSTALLED_APPS' list.

With these steps, you have completed the setup of your ORM project.

Everything was clear?

Section 1. Chapter 4
some-alt