← Back to all tutorials

Creating a Django Blog

Install Django, create a new project, understand the project structure, and run the development server for the first time.

Creating a Django Blog

Let us install Django and create our blog project.

Installing Django

# Create a virtual environment
python -m venv myenv

# Activate it
# Windows:
myenv\Scripts\activate
# Mac/Linux:
source myenv/bin/activate

# Install Django
pip install django

Creating the Project

django-admin startproject djangoblog .

The period (.) at the end creates the project in the current directory instead of a nested folder.

Project Structure

djangoblog/
├── manage.py            ← Command-line tool for the project
└── djangoblog/
    ├── __init__.py      ← Marks this as a Python package
    ├── settings.py      ← Project configuration
    ├── urls.py          ← URL routing for the project
    ├── asgi.py          ← ASGI config (async)
    └── wsgi.py          ← WSGI config (deployment)

Key Files

FilePurpose
manage.pyRun commands: server, migrations, create apps
settings.pyDatabase, installed apps, middleware, templates
urls.pyMaps URLs to view functions

Running the Server

python manage.py runserver

Visit http://127.0.0.1:8000/ — you should see the Django welcome page with a rocket. The development server auto-reloads when you change code.

Key Takeaways

  • Use a virtual environment to isolate project dependencies
  • django-admin startproject name . creates a new Django project
  • manage.py is the command-line tool for running the server, migrations, etc.
  • python manage.py runserver starts the development server on port 8000