Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Nov. 19, 2005 10:13:10

Andreas S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Handling large applications


Are there any guidelines for managing large applications with Django?
Most of the time it is possible to split those into several smaller
apps, but sometimes it isn't - what is the recommended way to handle
large apps? For example, does Django support splitting the models file
into several packages? This seems to be fairly easy for the views, but
the meta magic might make turning

models/
__init__.py
myapp.py

into

models/
__init__.py
myapp/
__init__.py
first.py
second.py

or maybe

models/
some_models/
__init__.py
first.py
second.py
other_models/
__init__.py
third.py
fourth.py
__init__.py
myapp.py

impossible (specifically, Django's internal get_module()-function and
the _MODELS attribute made some problems when I tried to do this).

Any hints?

Andreas

Offline

#2 Nov. 19, 2005 15:14:50

E.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Handling large applications


I can't help you on the whole problem (managing large applications),
but restricting to having a model in multiple files, see here:http://www.djangoproject.com/documentation/model_api/#models-in-multiple-filesBasically it's more or less the first option you proposed.

Cheers,

Emanuele

Offline

#3 Nov. 19, 2005 15:20:44

Jeffrey E.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Handling large applications


You seem to be pretty on top of things since you're already poking atthe internals of the model module magic, but just in case, I want tomake sure you've seen this:http://www.djangoproject.com/documentation/model_api/#models-across-filesand the section immediately following it.Also, it's not clear from your message whether you've actually *triedout* those model module configurations (using 'from django.models.xxximport yyy', of course) or if you only tried to verify it by goingstraight to get_module()...Regards,
Jeff


On Nov 19, 2005, at 5:12 AM, Andreas Stuhlmüller wrote:Are there any guidelines for managing large applications with Django?
Most of the time it is possible to split those into several smaller
apps, but sometimes it isn't - what is the recommended way to handle
large apps? For example, does Django support splitting the models file
into several packages? This seems to be fairly easy for the views, but
the meta magic might make turning

models/
__init__.py
myapp.py

into

models/
__init__.py
myapp/
__init__.py
first.py
second.py

or maybe

models/
some_models/
__init__.py
first.py
second.py
other_models/
__init__.py
third.py
fourth.py
__init__.py
myapp.py

impossible (specifically, Django's internal get_module()-function and
the _MODELS attribute made some problems when I tried to do this).

Any hints?

Andreas--
Jeffrey E. Forcier
Junior Developer, Research and Development
Stroz Friedberg, LLC
15 Maiden Lane, 12th Floor
New York, NY 10038
212-981-6540 212-981-6546http://www.strozllc.comThis message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No right to
confidential or privileged treatment of this message is waived or lost
by any error in transmission. If you have received this message in
error, please immediately notify the sender by e-mail or by telephone at
212.981.6540, delete the message and all copies from your system and
destroy any hard copies. You must not, directly or indirectly, use,
disclose, distribute, print or copy any part of this message if you are
not the intended recipient.

Offline

#4 Nov. 19, 2005 16:31:41

Adrian H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Handling large applications


On 11/19/05, Andreas Stuhlmüller <> wrote:
> Are there any guidelines for managing large applications with Django?
> Most of the time it is possible to split those into several smaller
> apps, but sometimes it isn't - what is the recommended way to handle
> large apps? For example, does Django support splitting the models file
> into several packages? This seems to be fairly easy for the views, but
> the meta magic might make turning
>
> models/
> __init__.py
> myapp.py
>
> into
>
> models/
> __init__.py
> myapp/
> __init__.py
> first.py
> second.py

Here are the two requirements for multi-module models:

* All the model modules have to live *directly* within the models
directory -- so the multi-level example you gave wouldn't work.

* In models/__init__.py, the __all__ variable must be set to a list of
all the model module names.

In practice, this isn't really a limitation. World Online (original
creators of Django) has quite a few large Django applications, and
putting all the models in a single "models" package isn't really a big
deal.

You can always split models across other *apps*, rather than creating
subdirectories within "models".

Hope this helps! Let me know if any of it wasn't clear.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org

Offline

#5 Nov. 19, 2005 17:08:53

Andreas S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Handling large applications


Adrian Holovaty wrote:
> * All the model modules have to live *directly* within the models
> directory -- so the multi-level example you gave wouldn't work.

Thanks, that's what I wanted to know. Multi-level models would have
been nice, but judging from the open tickets there are much more
important issues (and for models without a db table a small
modification of get_module is sufficient to make it work anyway).

Andreas

Offline

Board footer

Moderator control

Enjoy the 18th of November
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support