Built Our first project in Django?
Django article provides basic and advanced concepts of Django. My Django article is designed for beginners and professionals both.
what is Django?
Django is a web application framework written in Python programming language. It is based on MVT (Model View Template) design pattern. The Django is very demanding due to its rapid development feature. It takes less time to build application after collecting client requirement.
Django is used for creating web application, frontend development and full stack development, it is free and open source web framework.
Django was invented by Lawrence Journal-World in 2003 news paper for their web development. Django is developed by Adrian Holovaty and Simon willison. Initial release to the public was in July 2005.
let’s get start our first project in Django.
To check if your system has Python installed, run this command in the command prompt:
If you find that you do not have Python installed on your computer, then reffer my article https://medium.com/@wvrushali27/how-to-install-python-in-windows-5e96fb369607.
1. Create the Virtual Environment:
Next, we will need to create a virtual environment. We need to create one folder in D: drive and under the drive we will create virtual environment.
To create a virtual environment called myproject
Here, we create a virtual environment i.e myproject and also create a one folder in our windows D: drive which name is practice_django and under this folder our virtual environment is created.
- m stands for module, and it should be followed by an existing module name.
- venv is a built-in module that helps us create virtual environments
- myproject is the name of folder that will contains the virtual environment files and folders. we can also use the same name like venv but to avoid confusion , I pick up the somthing different than module name.
Activate virtual Environment
Now, we will need to activate the virtual environment. To do this, type
2. Install Django pacakge
First we check the Django package is installed or not, for this use the following command
- pip list
here, pip package not install so this section will teach you how to install Django on your system using pip. To do this, run the following command:
Once the installation is complete, you must verify that Django has been successfully installed. To do this, enter the following command:
3. Create Django project
Now it’s time to create a Django project. Every Django application will have only one project. We can have n number of applications or apps under a project. School can be project and Student, Teacher, Accounts all these are apps which are independent.
Once we execute above command it will create following things. Running above command creates a default folder structure, which includes some Python files and your management app that has the same name as your project:
4. Run your application
Now that the project has been created, it’s time to start the Django development server using the manage.py runserver command:
Make sure sure you are in the same directory as manage.py file after to run manage.py runserver.
Now, Go to http://127.0.0.1:8000/ in your web browser. You should see a page similar to the following screenshot:
We have successfully run our first Django project .
You have come to the end of this article. You learned how to install Django on Windows, verify the installation, and you also learned how to create a Django project and start a development server.
#vevcodelab
http://vevcodelab.com/