I have a strange problem with my form in django admin.
I have defined my form, model and modeladmin:
import datetime
from cmsplugin_news.admin import NewsAdmin as OldNewsAdmin
from django import forms
from django.db import models
from news.models import News
class NewNewsForm(forms.ModelForm):
class Meta:
model = News
fields = ('title', 'is_published', 'pub_date', 'is_featured')
class NewsAdmin(OldNewsAdmin ):
fields = ('title', 'is_published', 'pub_date', 'is_featured')
form = NewNewsForm
class News(models.Model):
title = models.CharField(_('Title'), max_length=255)
is_published = models.BooleanField(_('Published'), default=False)
pub_date = models.DateTimeField(_('Publication date'), default=datetime.datetime.now)
is_featured = models.BooleanField(_('Featured'), default=False)
admin.site.register(News, NewsAdmin)
All fields in the model seem to appear as well in the admin and form. But when I head to /en/admin/news/news/4/, I'm getting the following KeyError: key "is_featured" not found in form
Full stacktrace here https://dpaste.de/9yV3
Any help will be much appreciated. Thanks!
It seems there was a collision with other property. Changing the name made it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With