Backstory: I’ve always been terrified of backend and saw it as something mystical and way over my head. But I’ve decided that it’s time to face the beast and start diving into it. This is my journal on learning Django (along with Python where I have just some basic knowledge).
To be able to use Django, we first need to install Python. On Windows, we can download it from here, choose the right installer and make sure to check the box labeled “Add Python to PATH”.
The Windows installer incorporates pip3 (the Python package manager) by default so we can check installed packages with pip3 list
.
We then have to create a virtual environment to use Django (this will help us to keep the code tidy, we can skip this step but we don’t want to break the first principle of Python - Beautiful is better than ugly).
The steps for creating and working with a virtual environment are the following:
pip3 install virtualenvwrapper-win
mkvirtualenv my_python_environment
deactivate
workon
workon my_python_environment
rmvirtualenv my_python_environment
After we created the environment and we are in it, run pip3 install django
. Create and/or move into the folder we want to work. Run django-admin startproject myTestSite
to create a skeleton with the folders and files for managing the project. Change directory to myTestSite: cd myTestSite
.
To run the server type py manage.py runserver
. Go to http://127.0.0.1:8000/ to access the project. We could also change the port by writing the port number we want like this: py manage.py runserver 8080
Note: The prefix for Windows is py -3
, but it depends on how it was installed; if it doesn’t work, just try py
. The prefix for Linux/macOS is python3
.
Ana Filote Self-taught front-end developer. Trying to learn new things.