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.augus...@polytechnique.org> wrote:
> 
> 2015-02-18 6:34 GMT+01:00 Loïc Bistuer <loic.bist...@gmail.com>:
> 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-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/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/A38EDB7A-9099-49A1-B4EA-86BBF393B792%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to