#35456: Fieldset title inside StackedInline are `h3` but on errors are shown as
`h2`
------------------------------------------------+------------------------
               Reporter:  Natalia Bidart        |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  contrib.admin         |        Version:  5.0
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  1                     |
------------------------------------------------+------------------------
 Given the following models:

 {{{#!python
 from django.db import models
 from django.utils.timezone import now


 class Book(models.Model):
     title = models.CharField(max_length=100)
     author = models.CharField(max_length=100)
     publisher = models.CharField(max_length=100)
     publication_date = models.DateField(default=now)

     def __str__(self):
         return self.title


 class Cover(models.Model):
     book = models.ForeignKey(Book, on_delete=models.CASCADE)
     image = models.CharField(max_length=100)


 class Review(models.Model):
     book = models.ForeignKey(Book, on_delete=models.CASCADE)
     reviewer = models.CharField(max_length=100)
     content = models.TextField()
     creation_date = models.DateField(default=now)

     def __str__(self):
         return f"Review of {self.book.title} by {self.reviewer_name}"
 }}}

 And admin models:

 {{{#!python
 from django.contrib import admin

 from .models import Book, Cover, Review


 class CoverTabularInlin(admin.TabularInline):
     model = Cover
     fieldsets = (
         ("Cover Details", {
             "fields": ("image",),
             "classes": ("collapse",)
         }),
     )


 class ReviewStackedInline(admin.StackedInline):
     model = Review
     fieldsets = (
         (None, {
             "fields": ("reviewer",)
         }),
         ("History", {
             "fields": ("content", "creation_date"),
             "classes": ("collapse",)
         }),
     )



 class BookAdmin(admin.ModelAdmin):
     list_display = ("title", "author", "publisher","publication_date")
     search_fields = ("title", "author")
     list_filter = ("author", "publication_date")
     fieldsets = (
         (None, {
             "fields": ("title", "author")
         }),
         ("Advanced options", {
             "classes": ("collapse",),
             "fields": ("publisher", "publication_date",)
         }),
     )
     inlines = [
         CoverTabularInlin,
         ReviewStackedInline,
     ]


 admin.site.register(Book, BookAdmin)
 }}}

 When visiting the admin for a `Book`, the `ReviewStackedInline` shows
 fieldset heading using an `h3` tag, but on errors, it uses an `h2` tag
 (see screenshots attached). I think the correct tag to be used both with
 and without errors is an `h3`.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35456>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018f7d6dac9c-ae62bb3f-5734-48e0-ba52-9ae64960c9aa-000000%40eu-central-1.amazonses.com.

Reply via email to