How to run Django project | Django tutorial for Beginners
May 17, 2021 2022-12-19 7:26How to run Django project | Django tutorial for Beginners
How to run Django project | Django tutorial for Beginners
Introduction to Basic Django tutorial | How to run Django Project
Django is a Python-based web framework that has the ability to develop a high level of website or web applications. Because it is written in Python programming language which powerful libraries, we can use that library in Django website or web applications. So we have to learn how to run Django project, it is a very basic Django tutorial for beginners when they are learning from basic to advance. So there are different things you have to notice while running the Django project. Because when you start a Django project, you have to simply run a command to see the result on the browser.
Steps: How to run Django project
1. First of all, you have to create your Django project, optional: do some settings, as creating an application, including templates, manage static files, creating models, creating forms, etc
django-admin startproject projectName
2. After creating a project, you can run the project using this command
   python manage.py runserver
In the above command, python is showing, this command is related to Python programming (as Django is python based) manage.py is the python file which is used for different purposes, as creating database tables, creating superuser, etc And at the runserver is the command to run the server at that port which you set. The default port is 8080. But you can change this port as you want. For example,
   python manage.py runserver 5000
Now your project will run at 5000 port. The benefit of running a Django project on the different ports is that you can run or work on different Django projects.
Already have Project?
Already have project means if you have downloaded from the internet for your experience. Most of the time, developers download projects from GitHub to analyze the code of another experienced developer because they want to learn more logic and code style. That means if you have already a project, then what you have to do to run Django project because sometimes it creates some issues when you download a project from the internet and you want to run it. So let’s start to learn!
1. Open the project in visual studio code or another editor you want
2. If your already project is in a virtual environment then you have to Active the virtual environment. If you don’t know about the virtual environment, the following tutorials for you.
Django tutorials for beginners related to a virtual environment
What is a virtual environment for Django Projects | Django Tutorials
Why does Django need a virtual environment?
How to create a virtual environment in Django
How to run Django project | Django tutorials series
The above tutorials have more knowledge about virtual environments, if you are a beginner, you must-read.
But if the project is not using any virtual environment. Then go straight!
3. After that, you need to run a command which creates a migrations file for creating a database table.
   python manage.py makemigrations
If any changes are occurring then it will create a migrations file otherwise it says no changes detected.
4. Then run the following command (If the project is in Virtual environment, then activate the EN then run below command)
   python manage.py migrate
This command means, all the migrations will be applied, which mean in the database all the required tables and data will be created for this project
5. The next step is to run the requirements.txt file which contains all the dependencies a project needs.
To install all the packages in the requirements.txt, you have to run the below command
  $ pip install -r requirements.txt
You have to wait until all the packages are installed properly.
6. After doing this, your project is now ready to run, just run a command
   python manage.py runserver
Sure, your project will run properly, if your project did not run, then you can share your problem with us. we will try to solve your problem.
Conclusion
In this Django tutorial, we discuss on How to run Django project, this guide is for beginners students in a simple way. If you have any kind of confusion or problems yet with your project while running. Then share with us without hesitation.
If you use Facebook, Twitter, Pinterest, LinkedIn, or other social media platforms, then share this Django tutorial, if you share, more students will take the chance to learn.