On 21-7-2012 3:26, Russell Keith-Magee wrote:
> On Sat, Jul 21, 2012 at 3:32 AM, Nicolas Ardison <nicolas....@gmail.com> 
> wrote:
>> Hello, i was reading the Django documentation, and i have the following
>> trouble that i'm not sure if django can solve it. I have a application
>> called "userArea" and i want to extend that app with more app isolated from
>> the "main" apps.
>>
>> [DjangoProject]
>>
>> [APP1]
>>
>> [subAPP1]
>>
>> [subAPP2]
>>
>> [APP2]
>>
>>
>> Could i do something like this? anyone know where i can start reading about
>> this.
> 
> A Django app is just a Python module. That means you can nest them
> however you like. As long as you provide a fully qualified path the
> the leaf node of your nesting tree, you can use an app wherever it
> occurs in your Python module namespace.
> 
> However, you don't get any Django benefits out of nesting like this. A
> Django app is a single module. Nesting a module inside another doesn't
> mean that the Django app 'inherits' anything from its 'parent', or
> anything like that. The only benefit would be organisational -- i.e.,
> keeping all the code in a hierarchy so it's easier to find it later.

Well, this isn't completely true. As I said in earlier mail, you need
unique final part for INSTALLED_APPS.
Secondly, you can't organize models as you wish, meaning you can't do:
app/
    models/
           __init__.py
           mymodel.py

The model registry can't deal with it and lots of assumptions are done
in the code based on the fact that models are in a file called models.py
inside the application directory. I tried organizing models differently
like above and manually populating the application registry with them,
but I never could get it to work completely because of code like this:
./core/management/sql.py:
app_dir = os.path.normpath(os.path.join(os.path.dirname(
        models.get_app(model._meta.app_label).__file__), 'sql'))

For this reason it was more beneficial to use sub applications when
models.py grew rather big as no additional code was needed to populate
the app registry and things just work out of the box at a small cost of
having to register multiple apps in INSTALLED_APPS.
-- 
Melvyn Sopacua


-- 
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