Skip to main content

Claude/ChatGPT Prompt to Build a Production Django 5 + DRF API

Production Django 5 + DRF API with token auth, throttling, caching, tests, and Docker — return the project structure and key files.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt frames the model as a senior Django engineer and demands working code and real config -- structured so you can drop it into a fresh repo, not pseudocode. You supply [resource], [auth_model], and [deploy_target], and it returns a full Django 5 + DRF project: environment-split settings, viewsets and serializers, auth with throttling and caching, pytest-django tests, Docker, and migrations.

The structure works because it forces the parts teams skip. [resource] defines the viewsets, serializers, and object-level permissions, so the API is built around your real domain. [auth_model] sets whether you get token or JWT auth and how scoping works. [deploy_target] shapes the Dockerfile, gunicorn, and whitenoise setup. By making throttling, env-based settings, and real tests explicit deliverables, the prompt produces a production shape rather than a tutorial CRUD app. The base/dev/prod settings split also keeps secrets out of code and lets you tune behaviour per environment without editing application logic.

When to use it

  • You're starting a Python-first SaaS backend and want a production Django + DRF skeleton.
  • You need environment-split settings reading secrets from env vars, not a single settings file.
  • You want object-level permissions and per-user/per-anon throttling wired from the start.
  • You need pytest-django tests for CRUD, auth failures, permission denials, and throttle limits.
  • You want a Dockerfile, gunicorn, whitenoise, and docker-compose for local Postgres.
  • You need migrations, a seed command, and a README of run commands ready to go.
  • You need a seed command and a README of run commands so a teammate can boot it fast.

Example output

You get a file tree first, then the contents of each key file in fenced code blocks: the split settings, the DRF viewsets/serializers/permissions for your resource, the auth and throttling config, the pytest-django tests, the Dockerfile and docker-compose, and the seed command plus README. It's organized so you can recreate the repo file by file and run it locally, rather than stitch fragments together from an outline.

Pro tips

  • Describe [resource] with its relations (blog posts with authors and tags) so the serializers and permissions model the real shape.
  • Pick [auth_model] deliberately -- token vs JWT changes the auth flow and the scoping the prompt generates.
  • Set [deploy_target] accurately (Docker on a single VPS behind Nginx) so the Dockerfile and gunicorn config fit where it runs.
  • Wire throttling and its test (deliverables 3 and 4) first; it's the cheapest insurance against abuse on a public API.
  • Ask the model to apply caching only where it's safe so you don't accidentally cache per-user responses globally.
  • Run the generated pytest suite immediately; failing auth and throttle tests surface misconfiguration before deploy.
  • Keep the seed command idempotent so re-running it against local Postgres doesn't duplicate fixture rows.

Frequently Asked Questions

Does this prompt return runnable Django code or pseudocode?
It is instructed to return working code and real config, structured so you can drop it into a fresh repo. You get a file tree followed by each key file in fenced blocks, including settings, viewsets, tests, and Docker config, not pseudocode.
Can I choose JWT instead of token auth?
Yes. The `[auth_model]` variable controls the authentication approach, so you can specify DRF token auth or JWT. The generated auth flow, scoping, and the related tests adjust to whichever model you set rather than assuming one.
Does it include tests for throttling and permissions?
Yes. The pytest-django suite covers CRUD, auth failures, permission denials, and throttle limits as explicit deliverables. Wiring the throttle and its test in early is the cheapest insurance against abuse on a public API, so run the suite before deploying.
Is it set up for Docker deployment?
It produces a Dockerfile with gunicorn and whitenoise plus a docker-compose for local Postgres, shaped by your `[deploy_target]`. Set that variable accurately so the container and process config match where the API will actually run.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Django & Flask Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support