Journal / 04

Sannidhi Bhat

· Updated

Build a Portfolio Website With Django: A Beginner’s Guide.

By

Build a Portfolio Website With Django: A Beginner’s Guide — illustration

This tutorial walks through setting up a Django project from scratch — the same starting point you would use before building a portfolio site. Django is a Python web framework that handles routing, databases, authentication, and security conventions so you can focus on your application logic.

What is Django?

Django provides ready-made building blocks for web applications: URL routing, an ORM for databases, admin tools, form handling, and security defaults. You still write your own templates and views, but you do not need to assemble every low-level piece yourself.

Prerequisites

  • Python 3.10+ installed
  • A code editor such as VS Code
  • Basic familiarity with the terminal

Step 1: Install Python and VS Code

  1. Download Python from the official Python website.
  2. During installation on Windows, enable Add Python to PATH.
  3. Install VS Code and open it.
  4. Create a project folder on your computer and open it in VS Code (File → Open Folder).

Step 2: Create and activate a virtual environment

A virtual environment keeps this project’s Python packages isolated from other projects.

Open the integrated terminal in VS Code (View → Terminal) and run:

macOS / Linux

python3 --version
python3 -m venv env
source env/bin/activate

Windows

py --version
py -m venv env
env\Scripts\activate

When the environment is active, your terminal prompt usually shows (env).

Step 3: Install Django

With the virtual environment activated:

pip install django
django-admin --version

Step 4: Create the Django project

From your project folder (not inside the virtual environment folder itself):

django-admin startproject portfolio .

The trailing dot creates the project in the current directory. Django generates a manage.py file and a Python package also named portfolio containing settings, URLs, and WSGI/ASGI entry points.

Key files

  • manage.py — command-line utility for running the server, migrations, and other tasks.
  • portfolio/settings.py — project configuration.
  • portfolio/urls.py — root URL routing.
  • portfolio/wsgi.py / portfolio/asgi.py — deployment interfaces.

Step 5: Create a Django app

A Django project is the overall site; an app is a modular feature inside it (for example, pages for a portfolio).

python manage.py startapp portfolio_app

On Windows you can use py manage.py startapp portfolio_app if python is not on your PATH.

Register the app in portfolio/settings.py inside INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "portfolio_app",
]

Step 6: Run initial migrations and start the server

python manage.py migrate
python manage.py runserver

Open http://127.0.0.1:8000/ in your browser. You should see Django’s default welcome page.

Step 7: Add templates and static files

At the project root (alongside manage.py), create:

  • templates/portfolio_app/pages/home.html — HTML templates
  • static/ — CSS, JavaScript, and images

Add a simple home template:

<h1>Portfolio home</h1>
<p>Your Django project is running.</p>

Configure templates and static files in portfolio/settings.py:

from pathlib import Path

BASE_DIR = Path(__file__).resolve().parent.parent

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [BASE_DIR / "templates"],
        # ...
    },
]

STATIC_URL = "static/"
STATICFILES_DIRS = [BASE_DIR / "static"]

Step 8: Wire up URLs and a class-based view

Create portfolio_app/urls.py:

from django.urls import path
from .views import Home

urlpatterns = [
    path("home/", Home.as_view(), name="home"),
]

Update portfolio_app/views.py:

from django.views import View
from django.shortcuts import render

class Home(View):
    def get(self, request, *args, **kwargs):
        return render(request, "portfolio_app/pages/home.html")

Include the app URLs in portfolio/urls.py:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path("admin/", admin.site.urls),
    path("", include("portfolio_app.urls")),
]

Restart the development server and visit http://127.0.0.1:8000/home/. You should see your template rendered.

What’s next

You now have a working Django foundation: virtual environment, installed dependencies, project and app structure, templates, and a routed view. A follow-up article can extend this setup into a full portfolio layout with navigation, project pages, and deployment.

Comments

No comments yet.

Next

Building something similar?

Landings, sites, or product UIs — tell me the brief and I’ll reply with a clear next step.

Start a project