what I'm trying to do is divide up the views.py file into multiple
files because the single views.py file in some of my apps is getting
very cluttered.
I tried just making a views subdirectory and then placing multiple
files with groups of views inside, referencing to them in urls.py
with an extra dot with the name...
classic reference:
ProjectName.AppName.views.functionName (using a single views.py)
then I tried this:
ProjectName.AppName.views.viewGroupFileName.functionName
(with a directory called "views" in the Application Directory and a
python File "viewGroupFileName.py" in there that has a function
called "functionName" inside)
With this I get a ViewDoesNotExitst: No module named
viewGroupFileName.functionName.
Is it possible to divide up the view into multiple files? Is this
also possible with models?
thanks for any hints
- stefan
NRY
Ditto to what Nathan suggested about putting an
empty __init__.py into your new views directory,
but even if you want to break up your views file
it's not necessary to create a seperate directory.
You could organize it something along the lines of:
mysite/
myapp/
views_eggs.py
views_ham.py
An alternative would be to keep everything that's
exposed to your templates in views.py, and the
secondary stuff in other file(s):
mysite/
myapp/
views.py
utils.py
Then in views.py, import the stuff from utils.py:
# views.py
from mysite.myapp.utils import supervalidator, xfabulator
No changes are necessary to urls.py, and you keep all
the 'public' functions in a single file.
P.S. Cum grano salis: My Django experience is less than
a week old.
--
Jeff Bauer
Rubicon, Inc.
thanks again :)
-- stefan