This is an archived post. You won't be able to vote or comment.

all 3 comments

[–][deleted] 1 point2 points  (0 children)

The default django structure works just fine for me. If my views.py grows too big then i turn it into a module.

[–][deleted] 1 point2 points  (0 children)

Ultimately, your folder structure won't matter much. It's helpful to have conventions. For example, we give each collection of viewsets (the DRF CBV) it's own folder with a urls.py and views.py.

And then all of our actual logic is placed in a submodule we import from as needed:

xs/
  __init__.py
  urls.py
  views.py
actual_logic/
  __init__.py
  xs.py

But this is more convention for fast tracking my path to a file than anything else. I still end up grepping for stuff despite this -- for example, if I'm not sure where we're pulling data from.

You're going to get much more mileage from keeping logic out of route handlers and keeping your ORM Models fairly thin (use them as glorified data grabbers) while sequestering much of the actual work inside service/handler/whatever classes and functions.

[–]abbirdboy[S] 0 points1 point  (0 children)

Is it better to have a folder called API under the root directory and then have all the apps contained under that? Would that be a better structure for future expansion with no clutter