Last updated November 01, 2025
Originally published on October 26, 2025
Quickly test Django endpoints locally
Ever wanted to give your Django endpoints a go without a front end in place?
Turns out Django’s testing tools aren’t just for TestCase classes:
from django.test import Client
client = Client()
This little object is where all the magic begins - a simple yet powerful gateway for simulating requests.
Need to hit endpoints that require authentication? No problem:
from django.contrib.auth import get_user_model
...
user = get_user_model().objects.get(username="my-username")
client.force_login(user)
With that, you’re logged in and ready to make requests.
Here’s a quick example of a GET call:
...
client.get("http://localhost:8000/my-endpoint")
Running into issues with host validation? Specify the server name explicitly:
...
client.get("http://localhost:8000/my-endpoint", SERVER_NAME="mydomain")
And that’s it: a direct way to play with Django endpoints in your local environment.