If you want to build web applications with Python, Django is one of the best frameworks to start with. It gives you a strong structure, handles a lot of boilerplate for you, and helps you move from idea to working project faster.
In this guide, I’ll walk you through how to start a Django project from scratch in a clean and beginner-friendly way.
## Why use Django for web development?
Django is a powerful Python web framework that makes it easier to build secure, scalable, and maintainable web applications. It is a great choice if you want to create:
- websites and dashboards
- REST APIs
- admin panels
- content management systems
- full-stack web applications
It also comes with built-in features like authentication, an admin panel, ORM support, and migrations, which save a lot of time during development.
## 1) Create a virtual environment
Before installing Django, create a virtual environment. This keeps your project dependencies isolated and avoids conflicts with other Python projects.
``
bash
python -m venv .venv
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows
`
Once the environment is active, you are ready to install Django.
## 2) Install Django
Use pip to install the latest stable version of Django:
`bash
pip install django
`
You can verify the installation with:
`bash
django-admin --version
`
This confirms that Django is installed correctly in your environment.
## 3) Start a new Django project
Now create your Django project using the startproject command:
`bash
django-admin startproject myproject .
`
The . at the end is important. It tells Django to create the project in the current folder instead of making a separate nested directory.
After this, your project will include files like:
manage.py
settings.py
urls.py
asgi.py
wsgi.py
These files form the core structure of your Django project.
## 4) Run the Django development server
To check whether everything is working, run the development server:
`bash
python manage.py runserver
`
Then open your browser and visit:
`text
http://127.0.0.1:8000/
`
If you see the Django welcome page, your setup is successful.
## 5) Create your first Django app
In Django, a project is the full website, while an app handles one specific feature or module.
For example, you might create apps for:
- users
- blog posts
- payments
- products
- appointments
Create a new app with:
`bash
python manage.py startapp core
`
Then add core to INSTALLED_APPS inside settings.py.
## 6) Create a simple view
Now let’s make the app do something useful. Add a basic view inside core/views.py:
`python
from django.http import HttpResponse
def home(request):
return HttpResponse("Hello, Django!")
`
After that, connect the view to your URL configuration so Django knows what page to show when someone visits your site.
## 7) Use migrations to set up the database
One of Django’s biggest strengths is its database workflow. If you add models, Django helps you generate and apply database changes easily.
Run these commands:
`bash
python manage.py makemigrations
python manage.py migrate
`
Migrations keep your database schema organized and make future updates much easier.
## 8) Create a superuser for the admin panel
Django includes a built-in admin dashboard, which is one of its most useful features.
To access it, create a superuser:
`bash
python manage.py createsuperuser
`
After that, go to /admin/ in your browser and log in with your credentials.
## Best practices when starting a Django project
If you want your Django project to stay clean and scalable, keep these tips in mind:
- use a virtual environment from the start
- keep your settings organized
- separate apps by feature
- use meaningful names for models, views, and URLs
- commit your project structure early with Git
- test your work as you build
These small habits make a big difference later when the project starts growing.
## Final thoughts
Starting a Django project is not complicated once you understand the basic flow. Install Django, create a project, build an app, run migrations, and launch the development server. That’s enough to get moving.
The real learning begins when you start adding your own features, models, templates, and APIs. So don’t wait for the perfect setup — just start small and keep building.
If you're learning Django for the first time, this is the best way to get comfortable fast: build one small thing, run it locally, and keep improving from there.
## FAQ
What is the first command to start a Django project?
Use django-admin startproject myproject .`
Do I need a virtual environment for Django?
Yes, it is strongly recommended so your dependencies stay isolated.
What is the difference between a project and an app in Django?
A project is the full website, while an app is one part of the website built for a specific feature.
Can I start a Django project without creating an app?
Yes, but in most real projects you will create at least one app right away.