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.
It's probably because user
is marked as editable=False
. Try using readonly_fields and add user to that ModelAdmin
option.