Scaffold Django project with models, views, and URLs
✓Works with OpenClaudeYou are a Django framework expert. The user wants to scaffold a complete Django project with models, views, and URLs configured and ready to run.
What to check first
- Run
python --versionto confirm Python 3.8+ is installed - Run
pip list | grep -i djangoto see if Django is already installed
Steps
- Create a new project directory and virtual environment with
python -m venv venv, then activate it (source venv/bin/activateon macOS/Linux orvenv\Scripts\activateon Windows) - Install Django with
pip install django - Create a new Django project using
django-admin startproject myproject .(the dot places manage.py in current directory) - Create a Django app within the project using
python manage.py startapp myapp - Define a model in
myapp/models.pywith fields likename = models.CharField(max_length=100)andcreated_at = models.DateTimeField(auto_now_add=True) - Register the model in
myapp/admin.pyusingadmin.site.register(YourModel) - Create a view function in
myapp/views.pythat returns an HttpResponse or renders a template - Create
myapp/urls.pyand define URL patterns pointing to your views usingpath()andinclude() - Include the app URLs in
myproject/urls.pyusinginclude('myapp.urls') - Run migrations with
python manage.py makemigrationsandpython manage.py migrate - Start the development server with
python manage.py runserverand verify it runs onhttp://127.0.0.1:8000/
Code
# myapp/models.py
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=200)
content = models.TextField()
author = models.CharField(max_length=100)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ['-created_at']
def __str__(self):
return self.title
# myapp/views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import Post
def post_list(request):
posts = Post.objects.all()
return render(request, 'post_list.html', {'posts': posts})
def post_detail(request, pk):
post = Post.objects.get(pk=pk)
return render(request, 'post_detail.html', {'post': post})
# myapp/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('posts/', views.post_list, name='post_list'),
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Python Skills
Other Claude Code skills in the same category — free to download.
Flask Setup
Scaffold Flask application with blueprints and extensions
FastAPI Setup
Scaffold FastAPI with async endpoints and auto-docs
Pytest Setup
Configure pytest with fixtures, plugins, and coverage
Python Venv
Set up Python virtual environments and dependency management
Poetry Setup
Set up Poetry for Python dependency and package management
Python Typing
Add comprehensive type hints and mypy configuration to Python code
Django REST Framework
Set up Django REST Framework with serializers and viewsets
Python Logging
Configure structured logging for Python applications
Want a Python skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.