8

I have just created my first token based web API with Django-Rest-Framework and it has worked really well for my mobile applications.

I am about to start creating a website based on Django, but I would like to reuse as much of my API code as possible.

The options I can see are:

  • Create a basic Django application that consumes my DRF API, would have to add basic auth to my api?
  • Create a third application which contains all my models and logic and then import the code into the API and website application.

How do you normally approach this kind of code reuse with Django?

1 Answer 1

7
+50

This answer is based on my personal approach on the problem, both on industry and academic scenarios.

I value software decoupling. As such, I want to build smaller components, as reusable as possible. While presented with a similar problem, I've built the following components:

  • Django Rest Framework with authentication based token and complete REST API for all models;
  • Mobile application that interacts with the server using REST;
  • Web Application (in my case with AngularJS) that interacts with the application using REST.

This approach allows to have different teams working each on their own (backend, mobile, web). I could enumerate tens of advantages of adopting such approach, but I've paved the way and you can consult literature if needed.

Good luck

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.