David542
David542

Reputation: 110093

Breakdown of django code

In a well-conceived django project, what would be the approximate breakdown of code by file?

I feel that most of my code rests in the views.py file (other than my html templates). For larger sites, is there a single views.py file or is it usually spread across the site? Thank you.

Upvotes: 0

Views: 112

Answers (1)

spulec
spulec

Reputation: 837

Using separate apps is the best way to keep your code organized. Try to organize all of your models into separate groups and use this as a basis for your apps. Then pull the code for the associated views and urls to their respective apps.

In general I try to have no file more than a few hundred lines, but there are always exceptions. Also, moving methods that are based on models into the models.py file can help reduce the size of your views.

Upvotes: 1

Related Questions