Languages
[Edit]
EN

Python - install and run Django

0 points
Created by:
Haris65
386

In this article, we would like to show you how to install and run Python Web framework - Django.

To install Django you need to:

  1. create a new folder for your Django project,
  2. open Command Prompt and change directory to the Django project folder,
  3. create and activate a virtual environment,
  4. install Django,
  5. start the actual Django project.

Create and activate a virtual environment

After you create a new Django project and open Command Prompt with its directory create a new virtual environment using the following command:

python -m venv environment_name

then activate it using:

environment_name\Scripts\activate

Install Django

Now, when you have your virtual environment activated use the following command to install Django:

pip install django

Create the actual Django project

When you have Django installed use the command below to create an actual Django project:

django-admin startproject project_name

Start an app for the project

After you create the project, change the directory with cd project_name command and start an app using:

python manage.py startapp app_name

This will create a new directory called app_name.

Now open your project with some code editor (e.g Visual Studio Code), go to your project's settings.py file and add app_name to the INSTALLED_APPS list like this:

Django - add app to the INSTALLED_APPS in settings.py
Django - add app to the INSTALLED_APPS in settings.py

You can now run the app_name with the following command:

python manage.py runserver

You should get the result like this:

Now copy the selected fragment from your console and paste it in your browser to see if the install worked successfully.

Result:

Django - the install worked succesfully
Django - the install worked succesfully
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join