On Sat, 2008-11-29 at 12:48 -0800, David Elias wrote: > In my projects i often split models into several files inside a models > folder: > > some_app / > models / > __init__.py > some_models.py > other_models.py > ... > > I know i must set app_label in Meta options, but even so > Model._meta.installed returns false. In > django.db.models.options.Options i've changed: > self.installed = re.sub('\.models$', '', cls.__module__) in > settings.INSTALLED_APPS > > to this: > self.installed = re.sub('\.models.*', '', cls.__module__) in > settings.INSTALLED_APPS > capturing all from 'models'. > > Is this ok or it will break anything? At least for me is working. > > Another thing is that we must set the app_label, i've made another > change, in django.db.models.base.ModelBase we have: > kwargs = {"app_label": model_module.__name__.split('.')[-2]} > > In the above models layout the app_label would be "models", now is set > to "some_app" with this change: > parts = model_module.__name__.split('.') > kwargs = {"app_label": parts[parts.index('models')-1]}
Both of these changes look like they should work for your particular situation. They aren't a general solution to the problem -- although generalising to work correctly might not be too hard -- since you've changed the hard-coded assumption from zero levels of nesting to only one level of nesting. Which means that two levels of nesting will still break, etc. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---