How to Structure your Django Application with an API

I received an email asking how to structure your Django Project if you are using an API.

It’s common for people to want to know the best practices for structuring your code with your Django project.

People think that maybe if I can structure my project correctly, it would be easier to do X.

Want to get started learning Django REST Framework? Sign up for a FREE 7 Day Email Course today. Click here for more information

Sometimes your .py files can get so out of hand that you might want to break them up into smaller files.

Your API is just another Django app

But, How do you organize your API views and URLs?

You can do it pretty simply.

When I create an API using Django REST Framework, I’ll put my API code in it’s separate app and put all the views, URLs, Serializers, etc. inside that one directory. Everything is exactly the same.

I’ll update my URLs so that each route to my API starts with something like /api/v1/

Steps to creating an API

  1. Go into the directory with
  2. Run command to create a new app for your new API: python startapp api
  3. Update the URLConf and include the URLs for your API: url(r'^api/v1/', include('api.urls', namespace="api")),
  4. Add some files in your api folder:,, etc.
  5. Then, sign up for my Free Django REST Framework Email course to learn how to setup your own API.