The Django Journey #1 — Setting Up Your First Django Project
Welcome to The Django Journey – Episode 1
Welcome to the first episode of The Django Journey, where we take you step-by-step through learning Django, from initial setup to building real web applications. In this post, we’ll cover how to create your first Django project, set up your environment, and run the development server for the very first time.
What is Django?
Django is a powerful, open-source Python web framework that encourages rapid development and clean, pragmatic design. It helps developers build web applications quickly with less code by providing reusable building blocks like authentication, database management, URL routing, and templating.
Step 1: Prepare Your Environment
Before you start, ensure you have Python installed on your computer. Django works with Python 3.x versions. It’s a good practice to create a virtual environment for your projects to manage packages separately.
Open your terminal (Command Prompt, PowerShell, or shell) and run:
python -m venv myenv
Activate the virtual environment:
On Windows:
myenv\Scripts\activate
On macOS/Linux:
source myenv/bin/activate
Then install Django with pip:
pip install django
Step 2: Create a Django Project
Navigate to a directory where you want to keep your project code and run:
django-admin startproject mysite
This command creates a new folder named mysite containing the core files and settings of your Django project:
- manage.py: Command-line utility for administrative tasks
- mysite/: Package with settings, URLs, and application entry points
Your file structure will look like this:
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
Step 3: Run the Development Server
Change directory into the new project folder:
cd mysite
Run the Django development server:
python manage.py runserver
You should see output indicating the server is running on http://127.0.0.1:8000/.
Open your browser and visit that URL. Congratulations! You’ll see the Django welcome page confirming your project is up and running.
What’s Next?
You’ve successfully set up your first Django project and run it locally. Next, you’ll learn how to create Django apps—a modular part of your project—and build views to display content.
This journey will take you from zero to hero as you master Django’s core features and start crafting your own web apps.
Stay tuned for the next post in The Django Journey where we’ll create our first app and display a simple web page.
Comments
Post a Comment