My problem was actually a bit different. My problem involved model inheritence and the django.contrib.admin User model.
This caused the problem:
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.admin import UserAdmin
class AdminUser (UserAdmin):
fieldsets = UserAdmin.fieldsets + (
(_('APPS Info'), {'fields': ('agency', 'company')}),
)
where "agency" and "company" are fields of my User model that extends django's user model. Your solution of putting those fields in readonly_fields did fix the error, but then those fields were read only, which isn't what I wanted. I found that the problem was that the ModelForm used in django.contrib.admin was setting the model to Django's user model. So to fix it I added this:
from django.contrib.auth.admin import UserAdmin, UserChangeForm as DjangoUserChangeForm
from django.utils.translation import ugettext_lazy as _
from apps_models.users.models import User
class UserChangeForm(DjangoUserChangeForm):
class Meta:
model = User
class AdminUser (UserAdmin):
fieldsets = UserAdmin.fieldsets + (
(_('APPS Info'), {'fields': ('agency', 'company')}),
)
form = UserChangeForm
That's what I get for using Model inheritance... it isn't pretty, but it got the job done.
So it sounds like we were getting the same error, but for different reasons.