简体   繁体   中英

Django REST: projects vs apps

I am developing a REST API using Django Rest Framework. This API deals with a high number of resources that are divided into "business areas".

I should be developing this API so that the resources from the different business areas are independent and can be used individually in contexts other than the project I am working on.

My question is: should I be using different DRF projects, or different Django apps for each business area? Ie,

  • Should I organize like this:
|- businessarea1_api_project
  |- core_app
   |- api_documents 

|- businessarea2_api_project
  |- core_app
   |- api_documents 
  • Or like this:
|- big_api_project
  |- businessarea1_api_app

  |- businessarea2_api_app

I am assuming that using different apps helps me in the sense that I can use Django's reusable apps to create a package for each business area, and then I can install them in the projects they are required. Using different projects helps in the sense that i have an individual API running for each business area that can be called whenever needed, together with other APIs or not. Is this it? Are there other factors that I should be considering? Which one is better?

Thank you!

I would definitely go for the "big API project" way. You'll get:

  • the ability to "install" single apps into other project;
  • the opportuinity to create a common app for things like authentication, permissions, serialization, base models.
  • a nice catalog of all the business areas/apps
  • good karma for following Django guidelines on structuring projects
  • the ability to "turn off" specific business areas/apps, just by not listing them in the INSTALLED_APPS setting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM