Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guide in organizing large Django projects [closed]

Anyone could recommend a good guide/tutorial/article with tips/guidelines in how to organize and partition a large Django project?

I'm looking for advices in what to do when you need to start factorizing the initial unique files (models.py, urls.py, views.py) and working with more than a few dozens of entities.

like image 316
Sam Avatar asked Feb 09 '09 20:02

Sam


People also ask

How do I organize my Django project?

The way I like to organize my Django Project is – Keeps all Django apps in apps folder, static files (scripts, js, CSS) in the static folder, HTML files in templates folder and images and media content in the media folder.

Can Django be used for large projects?

No. The best thing in django is it's a package, you don't want to install library that supports django. Because it have everything in it. You can easily create static website using django.

How many apps should a Django project have?

Django comes with six built-in apps that we can examine.


1 Answers

Each "application" should be small -- a single reusable entity plus a few associated tables. We have about 5 plus/minus 2 tables per application model. Most of our half-dozen applications are smaller than 5 tables. One has zero tables in the model.

Each application should be designed to be one reusable concept. In our case, each application is a piece of the overall site; the applications could be removed and replaced separately.

Indeed, that's our strategy. As our requirements expand and mature, we can remove and replace applications independently from each other.

It's okay to have applications depend on each other. However, the dependency has to be limited to the obvious things like "models" and "forms". Also, applications can depend on the names in each other's URL's. Consequently, your named URL's must have a form like "application-view" so the reverse function or the {% url %} tag can find them properly.

Each application should contain it's own batch commands (usually via a formal Command that can be found by the django-admin script.

Finally, anything that's more complex than a simple model or form that's shared probably doesn't belong to either application, but needs to be a separate shared library. For example, we use XLRD, but wrap parts of it in our own class so it's more like the built-in csv module. This wrapper for XLRD isn't a proper part of any one application, to it's a separate module, outside the Django applications.

like image 157
S.Lott Avatar answered Sep 20 '22 19:09

S.Lott