Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When value is a list it should be returned as is #1340

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tony13tv
Copy link
Contributor

@tony13tv tony13tv commented Mar 7, 2021

This change should help close #1103

@codecov-io
Copy link

codecov-io commented Mar 7, 2021

Codecov Report

Merging #1340 (4c4d3f6) into main (b1e37af) will decrease coverage by 0.07%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1340      +/-   ##
==========================================
- Coverage   99.44%   99.36%   -0.08%     
==========================================
  Files          15       15              
  Lines        1265     1267       +2     
==========================================
+ Hits         1258     1259       +1     
- Misses          7        8       +1     
Impacted Files Coverage Δ
django_filters/widgets.py 99.37% <50.00%> (-0.63%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1e37af...4c4d3f6. Read the comment docs.

Copy link
Owner

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi thanks. All changes need to include a regression test.

@Przemek625
Copy link

Przemek625 commented Apr 1, 2021

@tony13tv @carlosgoce This change wont help because

value = super().value_from_datadict(data, files, name)
will execute following code

value = data.get(name)
where data is a QueryDict and thus for list it will return only last value

https://stackoverflow.com/a/39565140/6645337

this code helped me to achieve query in form /?param=1&param=2

from django_filters.fields import BaseCSVField
from django_filters.widgets import QueryArrayWidget

class MyBaseCSVField(BaseCSVField):
    base_widget_class = QueryArrayWidget


class MyBaseInFilter(df.BaseInFilter):
    base_field_class = MyBaseCSVField


class NumberInFilter(MyBaseInFilter, df.NumberFilter):
    pass


class MytFilter(df.FilterSet):
    id = NumberInFilter()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[2.1.0] BaseCSVWidget.value_from_datadict — AttributeError: 'list' object has no attribute 'split'
4 participants