Django ver 1.7 AppRegistryNotReady: models not yet loaded

I am trying to work with authentication tutorials to make sure everything works as expected. I entered the following code.

>>> from django.contrib.auth.models import User >>> user = User.objects.create_user('john', ' lennon@thebeatles.com ', 'johnpassword') >>> user.last_name = 'Lennon' >>> user.save() 

and I get an error

 AppRegistryNotReady: Models aren't loaded yet. 

I see from the release notes

The standard implementation of remove() for ForeignKey managers has changed from a series of calls to Model.save() to one QuerySet.update() call. The change means that pre_save and post_save signals arent sent more. You can use the keyword bulk=False argument to return to the previous behavior.

Therefore, I assume that this is a problem with a foreign key.

My question is: where can I use the attribute bulk=False or is there another solution?

+6
source share
1 answer

I suggest doing this before your code above:

 import django django.setup() 

Does it fix?

+15
source

Source: https://habr.com/ru/post/975550/


All Articles