Web development with Python Django is an exciting experience. As a beginner, though, I can vividly remember how challenging it was to set up my first ever Django project. Even getting the popular Django welcome page (shown below) was a “eureka” moment for me. In this shot, I will show you simple steps to do this very easily.
Have Python up and running on your machine and your favorite editor (be it Pycharm or VScode, either is fine).
Now make sure you have pip installed by executing the following command in the cmd:
python get-pip.py
pip help
Next, we create our virtual environment. We will call it djangoenv
. Remember to remain in this environment as long as we keep working on our project. This is a good practice that keeps our project dependencies away from other projects.
In our cmd, let’s execute the following:
python -m venv desktop/djangoenv
This creates djangoenv
, our virtual environment on the desktop.
To activate it and get it set to work, we change the directory to desktop and enter this command:
djangoenv\Source\activate.bat
pip install django
This will install the latest stable version of Django. If you want a different one, indicate this by attaching the version number of interest to the Django command.
You can confirm the installation using this command.
django-admin --version
begin
:django-admin startproject begin
begin
folder and the manage.py
file.mini begin
.python manage.py startapp minibegin
python manage.py runserver
ctrl
and clicking on the link to see the Django custom welcome page.There you have it. Try to create more projects and apps to get used to the whole process.