Django Polls Simplified — Installing Django
This is a continuation of the previous article on environment setup:
Prerequisites
- Python v3.10+
- Virtual Environment
NOTE:
I will use Conda to manage my virtual environment for this demo. There’s no big difference when using virtualenv or pipenv.
Installation
Creating a Virtual Environment
Using conda, I will create a virtual environment for this. Run the command on your terminal:
conda create --name django-polls python=3.12The command conda create --name django-polls python=3.12 creates a new isolated Conda environment named django-polls with Python version 3.12 installed. This ensures an independent environment for your Django project, preventing conflicts with other projects or system-level Python installations. The environment allows you to manage dependencies and maintain compatibility with Python 3.12. Once created, you can activate it using conda activate django-polls and install additional packages like Django specific to this environment, ensuring a clean and organized workflow.
To activate the environment, you run:
conda activate django-pollsTo deactivate:
conda deactivateWorking Directory
A working directory is the current folder where your program or command operates, serving as the default location for reading, writing, or executing files.
For an organized working project, create a directory and django-polls, and continue development from there.
You can open the directory on Visual Studio code:
code .Setting Up A Database
Django will use SQLite by default, so you don’t need to set it up.
In the later articles, we will integrate using Postgres.
Installing Django
On your activated environment, install Django:
pip install DjangoYou can test your installation by running the django-admin command:
django-admin(Take a minute to breathe 🧘♀️ 🧘♂️ , then move on to the next step)
