Loïc, the model_name is indeed the lower-case version of the object_name: https://github.com/django/django/blob/master/django/db/models/options.py#L203
On Wednesday, February 18, 2015 at 2:07:28 PM UTC+1, Loïc Bistuer wrote: > > Individual routers don't have a base class but we can add it to the master > router `django.db.router`. I've updated the PR with a > `router.allow_migrate_model` method. I don't know if we should document > this just yet. > > Internally we now treat anything other than `app_label` as a hint, but I > guess we should still document `model_name=None` as part of the official > signature. > > Speaking about `model_name`, it seems to be the lowercase version of > `_meta.object_name` (which is basically __name__). I didn't investigate > further, can you confirm that `_meta.model_name` is what we want? > > > On Feb 18, 2015, at 15:41, Aymeric Augustin < > aymeric....@polytechnique.org <javascript:>> wrote: > > > > 2015-02-18 6:34 GMT+01:00 Loïc Bistuer <loic.b...@gmail.com > <javascript:>>: > > Another option would be to make the signature `allow_migrate(self, db, > app_label, model_name=None, **hints)` and to put the model class in the > hints dict, the same way we pass `instance` as hint to the other routers. > > > > Yes, that's what I wanted to suggest after Andrew confirmed my suspicion > that we have to account for historical models. > > > > Perhaps the following convenience function can help factoring out the > arguments in the common case: > > > > def allow_migrate_model(router, db, model): > > return router.allow_migrate(db, model._meta.app_label, > model._meta.model_name, model=model) > > > > (This isn't a router method because there isn't a base class for > routers.) > > > > -- > > Aymeric. > > > > -- > > You received this message because you are subscribed to the Google > Groups "Django developers (Contributions to Django itself)" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to django-develop...@googlegroups.com <javascript:>. > > To post to this group, send email to django-d...@googlegroups.com > <javascript:>. > > Visit this group at http://groups.google.com/group/django-developers. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/CANE-7mVJpobigSdmEQt1NdkXOyjDWdPoEZJz4TVdVDeG9g%2BS2w%40mail.gmail.com. > > > > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9e07c5d3-7706-4873-bb7a-9224af94c35f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.