2017-03-01 3 views
1

Ich bekomme: "django.core.exceptions.AppRegistryNotReady: Modelle sind noch nicht geladen."Django: Benutzer Benutzermodell nicht geladen

Traceback (most recent call last): 
    File "./manage.py", line 8, in <module> 
    django.setup() 
    File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup 
    apps.populate(settings.INSTALLED_APPS) 
    File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate 
    app_config = AppConfig.create(entry) 
    File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 90, in create 
    module = import_module(entry) 
    File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module 
    __import__(name) 
    File "/home/daniel/testingChamber/djangoTut/home/__init__.py", line 1, in <module> 
    import views 
    File "/home/daniel/testingChamber/djangoTut/home/views.py", line 9, in <module> 
    from .forms import UserForm 
    File "/home/daniel/testingChamber/djangoTut/home/forms.py", line 4, in <module> 
    class UserForm(forms.ModelForm): 
    File "/home/daniel/testingChamber/djangoTut/home/forms.py", line 7, in UserForm 
    class Meta: 
    File "/home/daniel/testingChamber/djangoTut/home/forms.py", line 8, in Meta 
    model = get_user_model() 
    File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py", line 163, in get_user_model 
    return django_apps.get_model(settings.AUTH_USER_MODEL) 
    File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 192, in get_model 
    self.check_models_ready() 
    File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 131, in check_models_ready 
    raise AppRegistryNotReady("Models aren't loaded yet.") 
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet. 

Ich weiß nicht, was passiert. Ich bin neu in Django.

Die Version, die ich verwende, ist 1.10.6 und Python 2.7.12.

Was ist der richtige Weg, dies zu tun?

+0

http://stackoverflow.com/questions/25537905/django-1-7-throws-django-core-exceptions-appregistrynotready-model-arent-load – Mayank

+0

Können Sie den vollständigen Traceback in Ihre Frage einfügen? Es würde helfen, das Problem zu diagnostizieren. –

+0

In welcher App befindet sich 'UserForm'? Bitte zeigen Sie Ihre 'INSTALLED_APPS' Einstellung. – Alasdair

Antwort

1

Wenn die von @Mayank in Kommentaren vorgeschlagene Lösung nicht funktioniert. Hier ist eine Problemumgehung - irgendwie wird Ihre Formulardatei zum Zeitpunkt des Einstellungsimports importiert. Stellen Sie sicher, dass keine Datei in Einstellungen importiert wird, die letztendlich Ihre Formulardatei importieren. Importieren Sie diese Datei nicht in die Datei __init__.

+0

Ich hatte einen Import in eine __init__ Datei, die zum Testen verwendet wurde. Meine schlechte –

+0

Froh, es hat funktioniert. Bitte markieren Sie es als richtige Antwort, wenn es geholfen hat – hspandher

Verwandte Themen