1.  You must place a file __init__.py in each sub-directory (folder)
from which you will import, such as your models and views directories.

2.  The __init__.py in your models directory must import all modules
containing modules.  When you add an app to installed apps in
settings.py, django will import models in that app.  Normally this is
models.py and importing it causes the model classes to be defined, and
their __metaclass__ (do not confuse this with the Meta nested class)
registers the model.  This is how syncdb can know what models exist,
for example.  But in your case only models/__init__.py is imported,
unless that, in turn, imports the other modules.  I still can't
promise that this will work, since I don't know whether other parts of
django assume and test for the existance of an actual models.py file
in the app directory.

But. java practice notwithstanding, there is nothing wrong with having
several models in one models.py module, so why fight against the
design of django?  If your collection of models is truly so complex
that they should be separated into more than one module, then perhaps
your app is too complex, and should be refactored into multiple
applications.

On Wed, Dec 16, 2009 at 2:52 PM, Bruno Cordeiro <bfscorde...@gmail.com> wrote:
> I want to create folder inside the app folder eg:
>
> application
>          __init__.py
>          models.py
>          views.py
> manager.py
> ...
>
> i want to separate in folder, like, one folder to models when i put
> models class inside like:
>
> application
>       __init__.py
>       models
>                 partner.py
>                 anothermodel.py
>      views
>                index.py
>                partner.py
>
> why i can do it, with the best manner? i know if i make the import
> inside the normal like models.py file like below this work, but have
> the best way to do it?
>
> from application.models.partner import __all__
>
> --
>
> 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.
>
>
>

--

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.


Reply via email to