lundi 12 février 2018

from django.contrib.auth.models import User

I know that this question had been asked and answered already, but the solutions I saw so far are not solving the problem. I am trying to run the following command in python to authenticate users who log in a website I am currently building.

'from django.contrib.auth.models import User'

However, I am getting the following error:

'Traceback (most recent call last): "C:\Users\<user>\Documents\GitHub\MegaPortal\BackEnd\BackEnd\test.py", line 4, in <module> from django.contrib.auth.models import User File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\models.py", line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module> class AbstractBaseUser(models.Model): File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\base.py", line 100, in __new__ app_config = apps.get_containing_app_config(module) File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 244, in get_containing_app_config self.check_apps_ready() File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 127, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.'

What is weird is that this command gives an error when I run on atom, but when I run using Django's shell, it does not give any error. I have already tried putting in my settings.py file the following command

import django
django.setup()

but still nothing.

Any help is highly appreciated.




Aucun commentaire:

Enregistrer un commentaire