How to Structure your Django Application with an API

Posted by Chris Bartos on October 16, 2017

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.

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.

Django REST Framework Email Course

You'll get 1 lesson everyday for 7 days.
You'll learn:

  • Serializers
  • Request Methods
  • Endpoints
  • Basic Authentication
  • and more...
Powered by ConvertKit

Django REST Framework Documentation got you down? Just want to get SOMETHING working?

You can learn Django REST Framework in ONE week at about 15 - 30 minutes per day (1 lesson per day for the next 7 days).

Click the button below to sign up and start learning Django REST Framework today!

click here to receive the first lesson in minutes!
(once you sign up, you'll get a new lesson everyday for the next 7 days)

Get some value from this post? Please like and share this post because more people also deserve some value. :-)