Welcome to the Django Installation tutorial! In this lesson, we'll walk you through the process of installing Django, a powerful and versatile Python web framework. By the end of this tutorial, you'll be ready to dive into building your first Django project! π―
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It's built by experienced developers and is used by some of the world's biggest companies, including Instagram and Pinterest.
π‘ Pro Tip: Django makes it easy to build complex, database-driven websites quickly and efficiently, perfect for self-learners and professionals alike!
To follow along with this tutorial, you'll need:
Now that we've covered the basics, let's get started! To install Django, open your terminal or command prompt and type:
pip install djangoπ Note: If you encounter any issues during the installation, make sure you have the latest version of pip installed. You can update pip by running pip install --upgrade pip.
Once Django is installed, you can create a new project. In the terminal, navigate to the directory where you want to create your project, and run:
django-admin startproject mysiteReplace mysite with the name you'd like to call your project.
What command do you use to create a new Django project?
Navigate into your new project directory:
cd mysiteInside your project directory, you'll find several key files and directories. The most important ones are:
manage.py: A utility script for managing your Django projectmysite/: The main project directory, containing various subdirectories
mysite/settings.py: Settings for your projectmysite/urls.py: URL routing for your projectBefore we move on, let's ensure that Django is working correctly. In the terminal, navigate to the project directory and run:
python manage.py runserverIf everything goes well, you should see output similar to this:
Watching for file changes with StatReloader
Performing system check...
System check identified no issues (0 silenced).
You have 14 unapplied migration(s). Your project may not work correctly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
May 23, 2023 - 13:00:00
Django version 3.2.6, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Now, open your web browser and navigate to http://127.0.0.1:8000/. You should see the Django welcome page, confirming that your installation was successful! π
In the next lesson, we'll dive deeper into Django by exploring the settings.py file and creating our first Django app. Stay tuned! π
π Note: If you encounter any issues during this tutorial or have questions, don't hesitate to reach out in the comments below. Happy learning! π€