Fix 'Models aren't loaded yet' warning on import

categories.registration._process_registry was being called in
categories/__init__.py, but since Django 1.9 it hasn't been possible to
perform operations with models until the app registry is fully
loaded. Currently the `AppRegistryNotReady` exception is being caught
and printed, which means it is never actually executed on load.

Since this code isn't currently doing anything (other than emitting a
print() of a warning), I've removed it.
This commit is contained in:
Frankie Dintino 2019-03-08 11:14:10 -05:00 committed by Brent O'Connor
parent abec2164f2
commit 61e156b385
2 changed files with 11 additions and 13 deletions

View file

@ -21,16 +21,3 @@ __version__ = get_version()
default_app_config = 'categories.apps.CategoriesConfig'
def register():
from categories import settings
from categories.registration import (_process_registry, registry)
_process_registry(settings.FK_REGISTRY, registry.register_fk)
_process_registry(settings.M2M_REGISTRY, registry.register_m2m)
try:
register()
except Exception as e:
print(e)

View file

@ -3,11 +3,22 @@ from unittest import skip
from django.core import management
from django.core.management.base import CommandError
from django.db import connection
from django.test import TestCase
class TestMgmtCommands(TestCase):
@classmethod
def setUpClass(cls):
connection.disable_constraint_checking()
super(TestMgmtCommands, cls).setUpClass()
@classmethod
def tearDownClass(cls):
super(TestMgmtCommands, cls).tearDownClass()
connection.enable_constraint_checking()
def test_add_category_fields(self):
management.call_command('add_category_fields', verbosity=0)