Django complete setup

Hemasai NagothiHemasai Nagothi
2 min read

Django is a high-level Python web framework and is also open-source. Starting with the Django framework for web development is the most effective way to build a web app instead of creating it from scratch. And also it promotes clean, reusable code by following the MVC(Model View Controller) architectural pattern. Along with that, it has built-in ORM(Object Relation Mapping).

Okay, guys here in this article we will see how to setup the Django in window's

In the first step, we need to create a virtual environment because it will allow an isolated environment for your Python projects.

python -m venv <filename>

python -m venv virtual-env

To activate the virtual environment you this command

virtual-env\Scripts\activate.bat

virtual-env\Scripts\activate.bat

After activating the virtual environment it will show same as below.

Now we need to install Django in a virtual environment.

python -m pip install Django

After Django installed in your venv. we are creating our first project.

django-admin startproject myapp

These are the files that will be created in the project after we created the new project.

Mainly we are gonna use the settings.py and urls.py. In the settings.py we will be having the configuration of the application like database connection, timezone, secret key, and middleware. And also we can change the default configurations to custom configurations.

The below screenshot will tell you how it will be...

and also urls.py is used to define the routing patterns for your web application. It maps URLs to view functions or classes that handle specific requests.

manage.py is a command-line utility script that provides various tools for managing the Django project. It serves as an interface to interact with different aspects of project, such as database management, starting a development server, running tests, creating database migrations, and more.

The below command will execute the migration file and update the tables in the databse.

python manage.py migrate

To execute the project use the command.

python manage.py runserver

0
Subscribe to my newsletter

Read articles from Hemasai Nagothi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hemasai Nagothi
Hemasai Nagothi