On 27/09/2010 9:08, MrMuffin wrote: > Where do you put your business logic in django? In my project I`ve put > it into the models.py, but that file soon become huge and hard to > maintain. Of course I can just stuff it into whatever file I like, but > I`d like to have some standard way of doing this. There seems to be > something missing in django when it comes to business logic. It`s all > model, views and templates and that`s all great for small projects, > but both the models.py and views.py very soon gets huge and how do you > re-organize your project when that happens? Splitting views and models > into seperate files is only a partial solution and that requires some > hackish code in __init__.py to make syncdb etc work. And then there`s > urls.py. > > Should there be a better and standardized way to organize huge > projects in django? > > Thanks for your time. >
I would also like the Django guru's to come up with a best practices page. Just ideas of how you could structure code for this or that kind of project. You certainly can't cover all bases but at least it could serve as a starting point. On a related note, there is a thread about the SITE_ID. I can see how multiple sites can be managed from a single project but 1 project means 1 settings.py file so it's not clear to me how you can then use the SITE_ID. Anyway, as for structuring my code, I always end up splitting my models and views and as Bruno pointed out, using __init__.py isn't hackish but takes a bit getting used too. It's actually a nice Python feature. Dealing with a few smaller files is in my opinion more logical, cleaner and makes it faster to solve problems if they arise. Putting your business logic in your models is the preferred way it seems. If you have other code like utilities that aren't bound to http or django specific, i would put them in a another directory, make it package and install it so you can use it in any code/project. I have a big project that i'm working on and i'm putting all application related code, media and templates included, in the application directory. To me, it makes more sense to do it like this than to have a single template directory with sub directories for every application. This ties the apps into the project and i want to avoid this is possible so reusing the applications should be easier. Regards, Benedict -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.