carltongibson / django-filter

A generic system for filtering Django QuerySets based on user selections
https://django-filter.readthedocs.io/en/main/
Other
4.44k stars 767 forks source link

"Filters" button not showing if required fields are not passed #1669

Closed dontic closed 3 months ago

dontic commented 3 months ago

Coming from https://github.com/carltongibson/django-filter/issues/330#issuecomment-2165900104

When debuging an API it's super useful to have the image button.

Problem is that the button disappears if you have any required fields:

from django_filters.rest_framework import FilterSet
import django_filters
from .models import Message

class MessageFilter(FilterSet):
    user_email = django_filters.CharFilter(
        field_name="user__email", lookup_expr="exact", required=True
    )

image

It will come back again if you first pass the required fields via the URL.

Is there a way it can be shown even if the 400 error is there? Maybe also with a small red asterisk in the form fields that are required?

carltongibson commented 3 months ago

This is a DRF issue really. It's nothing really to do with the filter set. I haven't used DRF for a while, so I can't really say what the issue or workaround would be.

dontic commented 3 months ago

This is a DRF issue really. It's nothing really to do with the filter set. I haven't used DRF for a while, so I can't really say what the issue or workaround would be.

Gotcha, thanks for clarifying! Closing the issue then.