Reputation: 7635
I dont know why but the Django Admin App does not find the user field in the model. Can you help with that?
model.py:
from django.db import models
from django.forms import ModelForm
from django.contrib.auth.models import User
class object(models.Model):
name = models.CharField(max_length=50, )
user = models.ForeignKey(User, editable=False)
in_use = models.BooleanField()
admin.py:
from project.models import *
from django.contrib import admin
class ObjectAdmin(admin.ModelAdmin):
list_display = ['name', 'user', 'in_use']
Error message:
ImproperlyConfigured at /admin/
'ObjectAdmin.fieldsets[3][1]['fields']' refers to field 'user' that is missing from the form.
Upvotes: 1
Views: 1989
Reputation: 3800
It's probably because user
is marked as editable=False
. Try using readonly_fields and add user to that ModelAdmin
option.
Upvotes: 1
Reputation: 8506
you need to have the django.contrib.auth app activated in your INSTALLED_APPS in your settings and you have to set the name of your profile model in AUTH_PROFILE_MODULE,
AUTH_PROFILE_MODULE = "object"
Also, you should consider changing the name of your model, Python wont like you naming your model "object"
Upvotes: 0