mirror of
https://github.com/django/django.git
synced 2025-09-27 12:39:17 +00:00
Fixed #29682 -- Fixed admin change form crash if a view-only model's form has an extra field.
This commit is contained in:
parent
0e7a9525ba
commit
d311124be5
6 changed files with 36 additions and 3 deletions
|
@ -91,6 +91,14 @@ class ChapterXtra1Admin(admin.ModelAdmin):
|
|||
)
|
||||
|
||||
|
||||
class ArticleForm(forms.ModelForm):
|
||||
extra_form_field = forms.BooleanField(required=False)
|
||||
|
||||
class Meta:
|
||||
fields = '__all__'
|
||||
model = Article
|
||||
|
||||
|
||||
class ArticleAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
'content', 'date', callable_year, 'model_year', 'modeladmin_year',
|
||||
|
@ -101,10 +109,11 @@ class ArticleAdmin(admin.ModelAdmin):
|
|||
list_filter = ('date', 'section')
|
||||
autocomplete_fields = ('section',)
|
||||
view_on_site = False
|
||||
form = ArticleForm
|
||||
fieldsets = (
|
||||
('Some fields', {
|
||||
'classes': ('collapse',),
|
||||
'fields': ('title', 'content')
|
||||
'fields': ('title', 'content', 'extra_form_field'),
|
||||
}),
|
||||
('Some other fields', {
|
||||
'classes': ('wide',),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue