On Thu, 2009-03-19 at 12:53 -0700, Dan wrote:
> Hi all,
> 
> Is there a way to set app_label in the model Meta class dynamically?
> I'm trying to break up my models into separate files which now (as I
> understand) requires that each model specify it's app explicitly.
> However, I'd like to have my __init__.py in my models package handle
> this for me.

Not really, no. The app_label is processed when the file is imported
(because that's when the Model's __new__ method is run).

The proper solution here is for Django to work out the app_label more
appropriately in the automatic case -- perhaps walking up the module
tree until it hits something an app name. Fixing the real problem
correctly would be a better use of your time than trying to hack it like
this, I suspect (plus -- added bonus -- helping everybody). Note that
when people have tried to do this in the past, they've always forgotten
that directories can be nested to arbitrary levels and only allowed one
extra directory level, which isn't acceptable.

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