On 09/06/2016 12:55 PM, Aymeric Augustin wrote: > Hi Carl, > > Thanks for the feedback!
Of course! Thanks for working on things :-) > ... > The change I’m proposing doesn’t introduce random bugs. If models are > missing reverse relations, that will be deterministic. +1 >> Is it possible >> to make it so that even the model meta introspection APIs (and of course >> also any attempt to query the db) fail quickly, loudly, and with a clear >> error message if the app registry is not yet fully populated? If so, >> then I think there's little risk to adding this API (and in fact I think >> we could even make it the default behavior of `get_model`). > > If not checking for models_ready was the default for get_model(), then I’d > expect it to be the default for get_models() as well, but that doesn’t make > sense. get_models() really needs all models to be imported. > > My initial patch added a new method, `import_model`, because the operation is > quite different from the app registry's perspective. Instead of just looking > up the model, we try to import it. Even though the end result feels the same, > the context isn't the same. Yes, this makes sense. It suggests another possible name for the kwarg, `force_import=True`? ... > Without looking at the code base, I can’t say. It might help if you’re doing > swappable-model-style dynamic imports. It won’t help if you’re importing > models directly or indirectly from your applications’s __init__.py, which is > a more common problem. Yes, I think it's likely this wouldn't help much. > I think #21719 would have led there as well but it turned out to be > surprisingly hard -- in the realm of "not sure I'd get anywhere even if I > spent two weeks full-time on it”. I still think that's the right approach (and should be possible) in theory, but I trust your estimation of complexity and am currently short of two-week-plus blocks of free time :-) Carl -- 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 https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7d1c5071-b1c5-6fdb-e12c-7d7ebf3cb852%40oddbird.net. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: OpenPGP digital signature