Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create form field for 'created_by' yet, because its related model 'users.User' has not been loaded yet

Tags:

django

I recently installed Blogango, where I had the following error:

CommandError: One or more models did not validate:
 blogango.blogentry: 'created_by' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.

So I added settings.AUTH_USER_MODEL and now I get the following message:

ValueError: Cannot create form field for 'created_by' yet, because its related model 'users.User' has not been loaded yet

I went through my settings.py where it calls AUTH_USER_MODEL = 'users.User', and moved it higher up on the settings.py to try and get it load sooner.

As requested: created_by = models.ForeignKey(settings.AUTH_USER_MODEL, unique=False)

What can I do to fix this?

like image 766
Benjamin Bakhshi Avatar asked Nov 03 '22 17:11

Benjamin Bakhshi


1 Answers

It seems Blogango (is it https://github.com/agiliq/django-blogango?) does not support the custom user models introduced in Django 1.5.

The patch in Blogango should be pretty simple, just replace:

from django.contrib.auth.models import User

with:

from django.contrib.auth import get_user_model
User = get_user_model()

in django-blogango/blogango/models.py.

like image 103
Nicolas Cortot Avatar answered Nov 13 '22 01:11

Nicolas Cortot