On Mon, Sep 27, 2010 at 10:38 AM, bruno desthuilliers <bruno.desthuilli...@gmail.com> wrote: > On 27 sep, 09:08, MrMuffin <thomas.weh...@gmail.com> wrote: >> Where do you put your business logic in django? > > Depends on the definition of "business logic", but : > >> In my project I`ve put >> it into the models.py, > > That's also what I tend to do for anything that's not a pure utility > class or function and that's not strictly tied to the HTTP request / > response cycle. > >> but that file soon become huge and hard to >> maintain. > > > Then refactor your "models.py" module into a package. > >> 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. > > Using the package's __init__.py as a facade is certainly not "hackish" > - it's one of - if not the main - the raison d'ĂȘtre of this file. > > Now if your app is really growing that big, it's probably time to > refactor it into a set of related, more specialized apps. It's not as > easy as just splitting the models / views / whatever as sub-packages > of a same app, and doing so afterward will probably be more painful > than designing it right from the start, but in both cases it has the > benefit that it forces you to think about dependancies management, > which can greatly helps when it comes to maintainance.
Ok, I see your point, but still - there`s nothing about this in the main django documentation as far as I know. The docs should have a section about organizing projects where the standard models.py and views.py doesn`t fit anymore. -- Mvh/Best regards, Thomas Weholt http://www.weholt.org -- 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.