Opened 4 months ago

Closed 4 months ago

Last modified 4 months ago

#35556 closed Bug (duplicate)

The checkbox of a BooleanField is displayed before field's name

Reported by: Omid Shojaee Owned by: nobody
Component: contrib.admin Version: 5.0
Severity: Normal Keywords: checkbox
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

I have a BooleanField defined like this:

featured = models.BooleanField(verbose_name=_('featured'), default=False)

In the Admin site, I see the checkmark before the field name (screenshot is attached).

My site's language is Farsi, but I switched it to English and got the same thing.

I defined a BooleanField in another model, and again got the same thing.

I check the page in the Developer Tools and this is what I see:

<input type="checkbox" name="test_field" id="id_test_field">
<label class="vCheckboxLabel" for="id_test_field">Test field</label>

As far as I understand, this is wrong. The label element should be before input element not after it.

Django version: 5.0.6
OS: Ubuntu 22.0.4

Attachments (3)

Screenshot 2024-06-24 211617.png (1.6 KB ) - added by Omid Shojaee 4 months ago.
Screenshot 2024-06-24 224948.png (56.7 KB ) - added by Omid Shojaee 4 months ago.
Screenshot 2024-06-25 095603.png (21.8 KB ) - added by Omid Shojaee 4 months ago.

Download all attachments as: .zip

Change History (7)

by Omid Shojaee, 4 months ago

comment:1 by Natalia Bidart, 4 months ago

Component: Formscontrib.admin
Keywords: checkbox added; BooleanField Admin Site removed
Resolution: needsinfo
Status: newclosed

Hello Omid Shojaee, thank you for your report.

From the screenshot attached, it appears that the checkbox is positioned to the right of the label. To help us understand and address this, could you please provide the following details:

  • A larger screenshot showing the entire page to better grasp the context.
  • The complete model definition where the issue occurs.
  • If applicable, include any relevant views and forms that might be contributing to this behavior.
  • Could you describe the expected placement of the checkbox using terms like "left" or "right" to avoid any misunderstandings?

To better understand your concern about the "this is wrong" sentence, could you please provide additional information or references that explain the issue in more detail?

I'll close the ticket accordingly but please let me know when the information above is provided.

by Omid Shojaee, 4 months ago

comment:2 by Omid Shojaee, 4 months ago

This is the model definition:

class Product(models.Model):
    name = models.CharField(max_length=255, verbose_name=_('product name'))
    slug = models.SlugField(
        max_length=255, unique=True, allow_unicode=True, verbose_name=_('product slug')
    )
    brand = models.ForeignKey(
        Brand,
        on_delete=models.CASCADE,
        related_name='products',
        verbose_name=_('product brand'),
    )
    category = models.ForeignKey(
        Category,
        on_delete=models.CASCADE,
        related_name='products',
        verbose_name=_('product category'),
    )
    image = FileBrowseField(
        max_length=255,
        directory='products/',
        extensions=['.jpg', '.jpeg', '.png'],
        verbose_name=_('product image'),
    )
    quantity = models.PositiveIntegerField(
        verbose_name=_('product quantity'), default=0
    )
    price = models.PositiveIntegerField(verbose_name=_('product price'), default=0)
    featured = models.BooleanField(verbose_name=_('featured'), default=False)

    class Meta:
        verbose_name = _('product')
        verbose_name_plural = _('products')

    def __str__(self):
        return self.name

Looking at the second screenshot I attached, all fields are like this:

From left to right: Field name and then input box

Except for the boolean field, where the checkbox is to the left of the field name.

in reply to:  2 comment:3 by Natalia Bidart, 4 months ago

Resolution: needsinfoduplicate

Replying to Omid Shojaee:

From left to right: Field name and then input box

Except for the boolean field, where the checkbox is to the left of the field name.

Thank you for the extra details, I now understand your report and I see this is a duplicate of #28521.

The placement of the checkboxes (so they are to the right of a label) has been like this for ever. Any change in this area should be proposed, discussed, and agreed with the Django Community using the Django Forum.

by Omid Shojaee, 4 months ago

comment:4 by Omid Shojaee, 4 months ago

My third screenshot shows some of most common model fields.

I think someone from UI team should explain why Boolean field is different from the rest of the crowd.

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