otto-torino / django-baton

A cool, modern and responsive django admin application based on bootstrap 5 that brings AI to the Django admin - https://baton.sqrt64.it/
MIT License
891 stars 95 forks source link

Rows with only hidden inputs are displayed in admin forms #295

Open jackh-step opened 2 months ago

jackh-step commented 2 months ago

Rows containing only hidden inputs in admin forms are being displayed despite having the "hidden" class. This is related to "base.css" file containing the "hidden" class selector being shadowed.

abidibo commented 2 months ago

Hi @jackh-step please provide a sample code with just Model and ModelAdmin. Thanks

jackh-step commented 2 months ago

Hi @abidibo, thanks for responding, here's an example for reproduction.

class MyModel(models.Model):
    field = models.BooleanField()
    hidden_field = models.BooleanField()

class MyModelForm(forms.ModelForm):
    class Meta:
        model = models.MyModel
        fields = "__all__"
        widgets = {
            "hidden_field": forms.HiddenInput()
        }

@admin.register(MyModel)
class MyModelAdmin(admin.ModelAdmin):
    form = MyModelForm

In the above admin, even though the bottom row only contains a hidden input, it is still displayed for the reasons mentioned previously. The "hidden" class is applied if a fieldset's line has has_visible_field set to False, link to fieldset template.