Opened 6 years ago

Closed 6 years ago

#29982 closed Bug (needsinfo)

Change form fields don't appear on the same as requested in ModelAdmin.fields

Reported by: Artur Ivanov Owned by: nobody
Component: contrib.admin Version: 2.1
Severity: Normal Keywords: model admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

Hello. I've just updated django from 2.0 to 2.1.3 release and I have a problem with django admin site since.
The problem is incorrect html view of model admin fields option.

I have this code in my admin.py

@admin.register(Orders)
class OrdersAdmin(admin.ModelAdmin):
    fields = ('customer', ('order_number', 'order_date'), 'payment_day',
              'products', 'contact_pers', 'contractor', 'is_add_lic',
              'partner')

According to documentation fields order_number" and "order_date" must be on the same line because they're wraped in their own tuple. Вut it's broke since 2.1.0 release, as I guess.

To demostrate what I actually have I attached a couple of screnshots

Attachments (2)

2018-11-24_00-02-37.png (107.1 KB ) - added by Artur Ivanov 6 years ago.
2018-11-24_00-05-50.png (121.2 KB ) - added by Artur Ivanov 6 years ago.

Download all attachments as: .zip

Change History (6)

by Artur Ivanov, 6 years ago

Attachment: 2018-11-24_00-02-37.png added

by Artur Ivanov, 6 years ago

Attachment: 2018-11-24_00-05-50.png added

comment:1 by Artur Ivanov, 6 years ago

Component: Uncategorizedcontrib.admin

comment:2 by Tim Graham, 6 years ago

Description: modified (diff)
Summary: django model admin fields option has incorrect html viewChange form fields don't appear on the same as requested in ModelAdmin.fields

I haven't been able to reproduce this. Could you give a minimal project that demonstrates the issue? Ideally, you could also bisect to find the commit where the behavior changed.

comment:3 by Simon Charette, 6 years ago

I haven't been able to reproduce either with the following models and admin

from django.db import models

class Author(models.Model):
    title = models.CharField(max_length=100)
    first_name = models.CharField(max_length=100)
    last_name = models.CharField(max_length=100)
    dob = models.DateField(null=True)
from django.contrib import admin

from .models import Author

@admin.register(Author)
class AuthorAdmin(admin.ModelAdmin):
    fields = [ 
        'title',
        ('first_name', 'last_name'),
        'dob',
    ] 

The first_name and last_name appear side by side while title and dob are on their own lines.

comment:4 by Tim Graham, 6 years ago

Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top