Django REST framework → Postman collection

Turn your DRF routers, ViewSets and serializers into a complete Postman collection, including request bodies, JWT or Token auth, filters and pagination. You don't need an OpenAPI schema, drf-spectacular or drf-yasg.

$ pip install routeman && routeman generate

Why DRF teams use routeman

The usual route from a Django REST framework project to Postman goes through OpenAPI. You install drf-spectacular or drf-yasg, fix the warnings, annotate the views it can't understand, export the schema and import it into Postman. Then you still have to add login, tokens and environments by hand.

routeman skips all of that. It loads your URLconf the same way Django does and inspects the real view classes and serializers. You get a Postman collection that already knows how to log in.

What routeman reads from a DRF project

Example

# shop/serializers.py
class ProductSerializer(serializers.ModelSerializer):
    class Meta:
        model = Product
        fields = ["id", "name", "sku", "price", "status", "image"]
        read_only_fields = ["id"]

# shop/views.py
class ProductViewSet(viewsets.ModelViewSet):
    queryset = Product.objects.all()
    serializer_class = ProductSerializer
    filter_backends = [SearchFilter, OrderingFilter]
    search_fields = ["name", "sku"]
    ordering_fields = ["price"]

    @action(detail=True, methods=["post"])
    def publish(self, request, pk=None):
        ...

# shop/urls.py
router = DefaultRouter()
router.register("products", ProductViewSet)
urlpatterns = [
    path("api/v1/", include(router.urls)),
    path("api/v1/auth/token/", TokenObtainPairView.as_view()),
    path("api/v1/auth/token/refresh/", TokenRefreshView.as_view()),
]
$ routeman generate
✓ django: 10 requests (4 POST, 3 GET, 1 PUT, 1 PATCH, 1 DELETE)
✓ auth: bearer (login: POST /api/v1/auth/token/)
✓ wrote postman/shop-api.postman_collection.json
✓ wrote postman/shop-api.local.postman_environment.json
  done in 0.26s - import the files in Postman (File → Import)

This is real output for the code above. In Postman you get:

Path ids are named after the resource: /api/v1/products/{{product_id}}/, typed as UUID or integer from the model's primary key.

Step by step

  1. Activate the virtualenv you run manage.py with, then pip install routeman.
  2. From the folder that contains manage.py, run routeman generate. routeman uses DJANGO_SETTINGS_MODULE from manage.py, or pass -a config.settings.
  3. Import the files from postman/, select the environment, fill username/password and send Token.

The full walkthrough, including SimpleJWT, Knox and token-auth details, is in How to generate a Postman collection from Django REST framework.

DRF questions

Does it work alongside drf-spectacular?

Yes. routeman doesn't use or conflict with drf-spectacular or drf-yasg. Keep them for Swagger UI if you like. routeman reads the views directly either way.

What about views that build a serializer themselves?

Views that call SomeSerializer(data=request.data) are understood too. If a view uses no serializer at all, routeman reads request.data.get(...) calls in the view and marks the body as inferred.

My API uses TokenAuthentication, not JWT.

That's detected. The collection sends Authorization: Token {{access_token}}, and the login request stores the token (or Knox token) from the response.

Read the full docs