Open jaredahern opened 3 years ago
what about the name of the field name in the html widget that appears in the panel ?
will field_name
do the job ?
Also I am also fine to merge the fields and use only one of them if possible. The idea is to keep this as simple as possible while defining the filter class.
what about the name of the field name in the html widget that appears in the panel ?
Good point. Right now it is controlled via the title
class attribute. Should that default to field_name
if no separate title is provided?
Also I am also fine to merge the fields and use only one of them if possible. The idea is to keep this as simple as possible while defining the filter class.
Great, thanks for the feedback! I'll put together a PR for you to review.
@jaredahern, are you testing this against Django 3.2? If so, please keep in mind issue #53 as well.
Sure, I can test there too, @ndunn219 . I'm mostly done with my fixes, but I have one last bug that I'm trying to sort out before I create a PR. I haven't looked at it in great detail, but hopefully support for Django 3.2 won't be too complex of a change.
I'm doing a significant revamp to this filter, which will include things like more easily overridden widgets and fields, as well as support for multiple select. In the process of doing this, I ran into a point of confusion regarding our class variables - partially caused by my prior incorporated revisions. Basically, what do people expect
field_name
andparameter_name
to do in the case of relations that span multiple models?Example: you want to single-filter a
Book
model bypublisher__country
, whereBook.publisher
is a FK toPublisher.pk
andPublisher.country
is a FK toCountry.pk
.As far as I can tell, this is the current situation:
field_name
to be "country" andparameter_name
to be "publisher__country".field_name
.parameter_name
. A "base" version of this may be defined at the class level ("publisher__country"), which will be used to build the final version, orfield_name
will be the base.parameter_name
as above.But I think this is a bit sub-optimal, and confusing. Overwriting the class-level
parameter_name
is confusing and a bit contrary to how SimpleListFilter works, which complicates the factory version;parameter_name
is dual-used and doesn't allow custom non-lookup GET parameters; and while we only have README docs forfield_name
, it doesn't actually handle the nested relations, leading to user confusion.I propose that the filter should work as follows:
field_name
to be "publisher__country". If we don't want to use the auto-generatedparameter_name
for the GET parameter, specify that too.field_name
.parameter_name
(calculated fromfield_name
if omitted).field_name
.Alternatively, we could use something other than
field_name
as the main variable, clearly indicating that its old use is depreciated. Since we don't really even document how to handle nested relations now (I'll address that as well), I'm not too worried about breakage in a pre-1.0 version, but we can handle that however seems best.What say you all?