Lazily construct avatar and search registries on access.
Review Request #10512 — Created April 4, 2019 and submitted
We'd previously import and construct the avatar and search registries
when loading the
the first time. In modern versions of Django, this breaks app
initialization, since the imports end up importing other uninitialized
apps, resulting in hard-to-diagnose error messages.
To work around this, we now lazily import and construct the registries
when they're first needed. This has a side benefit of reducing the
startup load, even if just a bit. To do this, we use the new
lazy_import_registry()function in Djblets, which will construct a
wrapper around on the registries that does the import and construction
on first access, which will be some time after Django initialization has
Unit tests pass on Django 1.6 and 1.11 (with other in-progress changes).