Opened 21 months ago

Closed 20 months ago

Last modified 20 months ago

#34383 closed Bug (fixed)

Layout error in Admin when using help_text

Reported by: Antonio Candido Nazareth junior Owned by: Tom Carrick
Component: Template system Version: 4.2
Severity: Release blocker Keywords: help_text
Cc: Tom Carrick Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Antonio Candido Nazareth junior)

I'm using Django 4.2b1 and found a problem with the Django admin layout when I use the help_text in model admin. The help_text in the Admin form appears on a separate line and breaks the alignment of the fields. This happens in every browser I've tested.

Create a model with two or more fields that have help_text defined with a size larger than the field name. Register this model in admin.py with ModelAdmin and put them on the same line using fieldsets giving name to the line. Access the edit page of this model in Django admin and observe the layout.
Expected result:

The help_text should appear below the corresponding field, without affecting the alignment of the other fields.
https://code.djangoproject.com/attachment/ticket/34383/4.2b1.png

Attachments (3)

4.2b1.png (25.6 KB ) - added by Antonio Candido Nazareth junior 21 months ago.
Print erro on Django Version 4.2b1
4.1.7.png (26.1 KB ) - added by Antonio Candido Nazareth junior 21 months ago.
Print on Django Version 4.1.5 its ok
bug.jpg (147.1 KB ) - added by Antonio Candido Nazareth junior 20 months ago.
Error breaking line with two or more columns with help_text

Download all attachments as: .zip

Change History (14)

by Antonio Candido Nazareth junior, 21 months ago

Attachment: 4.2b1.png added

Print erro on Django Version 4.2b1

by Antonio Candido Nazareth junior, 21 months ago

Attachment: 4.1.7.png added

Print on Django Version 4.1.5 its ok

comment:1 by Antonio Candido Nazareth junior, 21 months ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 21 months ago

Resolution: needsinfo
Status: newclosed

Hi, I don't think you've explained the issue in enough detail to confirm a bug in Django. Do you have any custom templates? Please reopen the ticket if you can debug your issue and provide a sample minimal project that reproduces it.

by Antonio Candido Nazareth junior, 20 months ago

Attachment: bug.jpg added

Error breaking line with two or more columns with help_text

comment:3 by Antonio Candido Nazareth junior, 20 months ago

Resolution: needsinfo
Status: closednew

Steps to reproduce the error:
Create model new:

app.new.models.py

from django.db import models

class Favi(models.Model):
    faviNumero = models.CharField(max_length=20,help_text='Data incluindo o Horário do término da viagem')    
    matricula1 = models.CharField(max_length=50,help_text='Data incluindo o Horário do término da viagem')    
    matricula3 = models.CharField(max_length=50,help_text='Data incluindo o Horário do término da viagem')    
    matricula2 = models.CharField(max_length=50,help_text='Data incluindo o Horário do término da viagem')    
    matricula = models.CharField(max_length=50,help_text='Data incluindo o Horário do término da viagem')    
    objetivo = models.TextField(verbose_name='Objetivo', help_text='DESCRIÇÃO OBJETIVA DO SERVIÇO A SER EXECUTADO')
    
    periodoInicio = models.DateTimeField(verbose_name='Início',help_text='Data incluindo o Horário de início da viagem')
    periodoTermino = models.DateTimeField(verbose_name='Término',help_text='Data incluindo o Horário do término da viagem')

app.new.admin.py

from django.contrib import admin
from new.models import Favi

# Register your models here.
class FilterFaviAdmin(admin.ModelAdmin):
    fieldsets = [
    (None,                  {'fields':[('faviNumero','matricula1','matricula3'),'objetivo',('periodoInicio','periodoTermino'),('matricula2','matricula',),]}),    
    ]
admin.site.register(Favi,FilterFaviAdmin)

Result appears broken layout with help text as image below installed django pre version 4.2b1

https://code.djangoproject.com/attachment/ticket/34383/bug.jpg
works on django version 4.1.7

comment:4 by Mariusz Felisiak, 20 months ago

Cc: Tom Carrick added
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Thanks for details!

Regression in 96a598356a9ea8c2c05b22cadc12e256a3b295fd.

comment:5 by Mariusz Felisiak, 20 months ago

I tried to fix this, it's much better (but not perfect, you can see minor issues on the "Change user" view) with the following diff.

[REMOVED as can be confusing]

Last edited 20 months ago by Mariusz Felisiak (previous) (diff)

comment:6 by Tom Carrick, 20 months ago

Owner: changed from nobody to Tom Carrick
Status: newassigned

comment:7 by Mariusz Felisiak, 20 months ago

Has patch: set
Triage Stage: AcceptedReady for checkin

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

Resolution: fixed
Status: assignedclosed

In d687febc:

Fixed #34383 -- Fixed layout of admin fieldsets with multiple fields on the same line.

Thanks Antonio Candido Nazareth junior for the report.

Regression in 96a598356a9ea8c2c05b22cadc12e256a3b295fd.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@…>

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

Resolution: fixed
Status: assignedclosed

In 788f7b81:

[4.2.x] Fixed #34383 -- Fixed layout of admin fieldsets with multiple fields on the same line.

Thanks Antonio Candido Nazareth junior for the report.

Regression in 96a598356a9ea8c2c05b22cadc12e256a3b295fd.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@…>

Backport of d687febce5868545f99974d2499a91f81a32fef5 from main

comment:10 by GitHub <noreply@…>, 20 months ago

In b347dc6:

Refs #34383 -- Corrected margins in admin fieldsets with multiple fields on the same line on small screens.

Regression in d687febce5868545f99974d2499a91f81a32fef5.

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 20 months ago

In 47530bf:

[4.2.x] Refs #34383 -- Corrected margins in admin fieldsets with multiple fields on the same line on small screens.

Regression in d687febce5868545f99974d2499a91f81a32fef5.
Backport of b347dc63d5468564cbb7050461565f4f89032664 from main

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