gignosko
gignosko

Reputation: 987

Django CMS FieldError: Local field 'created_by' in class 'PageUser' clashes with field of similar name from base class 'User'

I have an existing django 1.9 application on python 3.5 and I'm trying to bring django cms into it. Right now, I'm following the manual install instructions here: http://docs.django-cms.org/en/release-3.3.x/how_to/install.html

I want to use the existing postgres db for storing cms data. Right now, all I've done is add the cms apps to INSTALLED_APPS as well as the middleware and the templates, all in the settings file. When I launch my app I get the FieldError:

django.core.exceptions.FieldError: Local field 'created_by' in class 'PageUser' clashes with field of similar name from base class 'User'

I ran through this http://docs.django-cms.org/en/develop/reference/configuration.html#custom-user-requirements and made sure our custom User was inheriting properly and had the right fields and methods.

Our custom User model does inherit from a custom mixin that adds a created_by to the user model.

I can't find a workaround that solves this. Any suggestions would be greatly appreciated.

Upvotes: 0

Views: 444

Answers (1)

Arghya Saha
Arghya Saha

Reputation: 5733

You should rename the field. Something like this

class PageUser(User):
    page_user_created_by = models.ForeignKey(settings.AUTH_USER_MODEL, 
                                             related_name="created_users", db_column='created_by')

You can read more about it here

Upvotes: 0

Related Questions