Opened 9 years ago

Closed 9 years ago

#24976 closed Bug (fixed)

admin.TabularInline custom form field header displaying as None on admin page

Reported by: Kartik Anand Owned by: matiasb
Component: contrib.admin Version: 1.8
Severity: Normal Keywords: TabularInline
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

While using admin.TabularInline with a custom form, for any form field if one doesn't specify a label, then it would come up as "None" on admin page, but one doesn't need to specify it for admin.StackedInline.

Attached Image

To reproduce:

models.py

from django.db import models

class Foo(models.Model):
    title = models.CharField(max_length=128)

    class Meta:
        verbose_name = "Foo"
        verbose_name_plural = "Foo"

    def __str__(self):
        pass

class Bar(models.Model):
    title = models.CharField(max_length=128)
    foo = models.ForeignKey(Foo)

    class Meta:
        verbose_name = "Bar"
        verbose_name_plural = "Bars"

    def __str__(self):
        return self.title

admin.py

from django.contrib import admin
from django import forms
from . import models

class BarInlineForm(forms.ModelForm):
    title = forms.CharField(max_length=128)
 
    class Meta:
        model = models.Bar
        fields = ('title',)
 
class BarInline(admin.TabularInline):
    model = models.Bar
    form = BarInlineForm
    extra = 3

class FooAdmin(admin.ModelAdmin):
    inlines = [BarInline]

admin.site.register(models.Foo, FooAdmin)

Attachments (1)

Screenshot from 2015-06-12 19:29:22.png (22.6 KB ) - added by Kartik Anand 9 years ago.
Screenshot of admin page

Download all attachments as: .zip

Change History (5)

by Kartik Anand, 9 years ago

Screenshot of admin page

comment:1 by Tim Graham, 9 years ago

Easy pickings: unset
Triage Stage: UnreviewedAccepted

comment:2 by matiasb, 9 years ago

Owner: changed from nobody to matiasb
Status: newassigned

comment:3 by matiasb, 9 years ago

Has patch: set

Pull request created: https://github.com/django/django/pull/5403
All tests passing for SQLite.

comment:4 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 12aeed8:

Fixed #24976 -- Fixed missing form label in tabular inline.

If the model form had a form field specified, the label rendered
as "None".

Note: See TracTickets for help on using tickets.
Back to Top