#14948: Broken routers in 1.2.4: type object 'ModelBase' has no attribute '_meta' ------------------------------------------+--------------------------------- Reporter: shell_dweller | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: 1.2 Keywords: router, ManyToManyField | Stage: Unreviewed Has_patch: 0 | ------------------------------------------+--------------------------------- There is a problem with using routers in the latest security release 1.2.4. The details are somewhat murky for a lay person but here's the gist of it:
* The site has a routing scheme setup as described in http://docs.djangoproject.com/en/1.2/topics/db/multi-db/#using-routers * Attempt to save any model with a ManyToManyField fails in router when trying to execute db_for_write: {{{ def db_for_write(self, model, **hints): if model._meta.app_label == 'my_app_label': return 'my_db_name' return None }}} Error message is "type object 'ModelBase' has no attribute '_meta'". It seems that the error occurs in django/db/models/fields/related.py, line 624 where {{{ self.through.__class__ }}} returns ModelBase whereas prior to 1.2.4 it used to be a user defined class. Here's the stack trace: {{{ [ snip ] File "/usr/lib/python2.4/site-packages/django/forms/models.py", line 375, in save fail_message, commit, construct=False) File "/usr/lib/python2.4/site-packages/django/forms/models.py", line 87, in save_instance save_m2m() File "/usr/lib/python2.4/site-packages/django/forms/models.py", line 83, in save_m2m f.save_form_data(instance, cleaned_data[f.name]) File "/usr/lib/python2.4/site- packages/django/db/models/fields/related.py", line 1144, in save_form_data setattr(instance, self.attname, data) File "/usr/lib/python2.4/site- packages/django/db/models/fields/related.py", line 730, in __set__ manager.clear() File "/usr/lib/python2.4/site- packages/django/db/models/fields/related.py", line 506, in clear self._clear_items(self.source_field_name) File "/usr/lib/python2.4/site- packages/django/db/models/fields/related.py", line 624, in _clear_items db = router.db_for_write(self.through.__class__, instance=self.instance) File "/usr/lib/python2.4/site-packages/django/db/utils.py", line 134, in _route_db chosen_db = method(model, **hints) File "/path/to/my/app/routers.py", line 10, in db_for_write if model._meta.app_label == 'my_label': AttributeError: type object 'ModelBase' has no attribute '_meta' -- Ticket URL: <http://code.djangoproject.com/ticket/14948> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.
