HOME BLOGS ABOUT CONTACT

How to Create a Django Project with UV Package Manager (Step-by-Step Guide)

tania andrew Suresh Thapa
| 19 Sep, 2025 | 804 views
0
0
How to Create a Django Project with UV Package Manager (Step-by-Step Guide)

Getting Started with Python’s UV Package Manager (with Django Example)

Python developers have long relied on package managers like pip and pipenv, but a new tool called uv is gaining traction for its speed, simplicity, and modern developer experience. Built by Astral, uv is designed to be a drop-in replacement for pip/pip-tools/poetry while being significantly faster.

In this guide, we’ll explore the basics of uv and see how to create and run a Django project using it.

 

Why UV?

  • Blazing fast: uv is written in Rust and optimized for speed.
  • Simple workflows: It unifies dependency management, environments, and project scaffolding.
  • Modern replacement: Works as an alternative to pip, pip-tools, and poetry.
  • Cross-platform: Works on Linux, macOS, and Windows.

 

Install UV via PIP.

pip install uv

or go to https://docs.astral.sh/uv/getting-started/installation/ for more details.

 

Step 1: Initialize a New Project

uv init

This creates a new project directory with configuration files (pyproject.toml) that uv uses to manage dependencies.

 

Step 2: Add Django as a Dependency

uv add django

uv will update the pyproject.toml and lock file, and install Django into a virtual environment automatically.

 

Step 3: Start a New Django Project

uv run django-admin startproject django_project .

This creates a new Django project in the current directory.

 

Step 4: Run the Development Server

uv run manage.py runserver

Open http://127.0.0.1:8000/ in your browser and you’ll see the default Django welcome page.

 

Step 5: Create a Django App

uv run manage.py startapp app1

This generates a new app structure (app1/) where you can define models, views, and templates.

 

Step 6: Apply Migrations

Whenever you add or modify models, you need to create and apply migrations.

Create new migration files:

uv run manage.py makemigrations

 

Apply migrations to the database:

uv run manage.py migrate

This sets up Django’s default tables (auth, admin, sessions, etc.) in your database and applies your app’s model changes.

 

Why Use UV for Django?

  • No need to activate/deactivate venvs – uv handles environments automatically.
  • Cleaner dependency management – no more juggling requirements.txt manually.
  • Modern tooling – uv is built for performance and scales well for bigger projects.

 

 

Final Workflow Recap

Here’s the full set of commands to get started with Django using uv:

uv init
uv add django
uv run django-admin startproject django_project .
uv run manage.py runserver
uv run manage.py startapp app1
uv run manage.py makemigrations
uv run manage.py migrate

With just these commands, you have a fully working Django project managed by uv .

 

Tags:

django python uv

Comments

Please login to leave a comment.

No comments yet. Be the first to comment!