Steps : To create Django 3 project quickly in minutes

Listen as audio
Image by FreeCliparts from Pixabay

Hello Techies,

In this blog, we will learn steps to create Django 3 Project. In this blog, I’m giving you the Django example project and also tell you how to run Django 3 projects in cmd.

Introduction

  • Django is an open-source framework that’s primarily based on the python programming language.
  • Django software foundation maintains the Django Framework.
  • Django is based on the MVT(Model-View-Template) pattern.
  • Django offers many modules like Authentication, Admin Panel, Contact forms, File upload, and support, and more.
  • Django offers many modules like Authentication, Admin Panel, Contact forms, File upload, and support, and more.
  • Today, many websites are built with Django Framework like YouTube, Instagram, Bit Bucket, Spotify, etc.

Steps To Create Django 3 Project

Let’s start to create Django 3 project step by step in 2020. As Django Framework is based on python language so we require python installed in our machine. After Python, installation we need Virtual Environment, Pip and after virtual activation using pip install Django.

After Python installation, we need Virtual Environment, Pip and after virtual activation using pip install Django.

The above installation is the first step to create a Django 3 project. so you can refer to my previous blogs, where I have covered Django installation in Ubuntu Linux and Windows Machine. Check below installation links.

Django Installation on Windows machine

https://techpluslifestyle.com/technology/how-to-install-django-3-on-windows

Django Installation on Ubuntu Linux machine

https://techpluslifestyle.com/technology/how-to-install-django-3-on-ubuntu

Now I assume that you have met all the above-said requirements, let’s proceed further. Let’s Start to create Django 3 project. For this, you have to open the command prompt or if you are using pycharm editor so you can open the console in pycharm also the choice is yours.

  • First, we have to activate the virtual environment.
  • Now to check Django installed or not in your activated environment using (pip freeze) command.
  • Command to check the Django version using below or you can check by using pip freeze
python -m django --version

Creating A Django Application

  • Command to create an app
django-admin startproject demo
  • The above command will create the demo directory in the current directory.
  • Let’s look at the demo directory structure, which files have been created, and the use of that files.
    1. demo/: This outer root directory is a container of all Django app-related files. If you want to change the name of this directory you can change it.
    2. demo/demo: The inner demo directory is an important directory which is your actual Python package for your project.
    3. demo/manage.py: This is an automated file in each Django app. This is the thin wrapper on django-admin that takes care of below 2 points:
      1. Puts your project on sys.path.
      2. Sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project setting file.
    4. demo/demo/__init__.py: This is a blank file and this file tells python to consider this as a python package.
    5. demo/demo/settings.py: This is the configuration file where you can add new  modules, configure database details, handle static folder, templates, etc.
    6. demo/demo/urls.py: In this file, all the URL patterns are declared.
    7. demo/demo/asgi.py: An entry-point for ASGI-compatible web servers to serve your project.
    8. demo/demo/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project.

Django create app command

python manage.py startapp api

Now we will check how to run Django project in cmd

Command to run the Django application

python manage.py runserver

Open your application Locally on any browser and hit below URL.

http://127.0.0.1:8000  OR  http://localhost:8000

By default, the application runs on 8000 port.

Congratulations Django installation has been done successfully. Now you can create Django 3 project in any domain.

Hope this blog will be helpful for you to create Django 3 project. Get in touch with our blogs where we are going to cover many topics related to the Django projects and much more about technology as well as lifestyle routine. please share this blog with your friends and If you have any queries do comment below.

Leave a Comment