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.
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.
精彩评论