To install Django on your machine, you can follow these steps. Note that these instructions assume you have Python already installed on your system. If not, you'll need to install Python first.
Visit the Python official website to download and install the latest version of Python. Follow the installation instructions for your operating system.
Using a virtual environment is a good practice to keep your project dependencies isolated. Open a terminal or command prompt and navigate to the directory where you want to create your Django project.
bash# On Windows
python -m venv myenv
cd myenv\Scripts
activate
# On macOS/Linux
python3 -m venv myenv
source myenv/bin/activate
With your virtual environment activated, use the following command to install Django using pip (Python's package installer).
bashpip install django
You can verify the installation by checking the Django version:
bashpython -m django --version
This command should display the installed Django version.
Now, you can create a new Django project using the following command:
bashdjango-admin startproject myproject
Replace "myproject" with the desired name for your Django project.
bashcd myproject
Start the development server to see if everything is working:
bashpython manage.py runserver
Visit http://127.0.0.1:8000/
in your web browser, and you should see the default Django welcome page.
That's it! You've successfully installed Django on your machine. You can now start building your Django web applications.