On Mon, 2009-08-10 at 20:51 -0700, MattR wrote:
> Are there any best practices documents to organizing large Django
> projects?
> 
> Should the view code be in a file called views.py?  It seems like this
> file could get rather large and hard to manage, is there some
> suggested way to break it up?

View functions are just Python functions that are called with particular
parameters (request + any arguments from the URL pattern). So you can
put them literally anywhere that is on your Python path. They don't even
have to reside in applications, although it's not a bad idea to do so.

You definitely don't have to call the module views.py and it's not
uncommon to break it up into, say, a views/ directory containing a bunch
of files with related views in each file.

> 
> Should the files with views even be called views.py, or should the
> filename indicate the functionality of the view?

I tend to go for separate filenames for separate functionality. I'll
often have views that change data in one file, views that are for
read-only things in another file and forms in other files, again, maybe
grouped by functional groups.

Also remember to look at how you split things into applications. A
Django "project" is really just a settings file and a root URL Conf
file. The settings file contains a list of applications that are used
and finding a nice separation of your functionality into applications is
a really good idea and pays off in spades down the road.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to