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

'AdvancedFilterQueryForm' object has no attribute 'cleaned_data' #141

Closed
DuSheridan opened this issue Apr 26, 2021 · 18 comments
Closed

'AdvancedFilterQueryForm' object has no attribute 'cleaned_data' #141

DuSheridan opened this issue Apr 26, 2021 · 18 comments

Comments

@DuSheridan
Copy link

DuSheridan commented Apr 26, 2021

Describe the bug

Trying to create any new filter leads to AdvancedFilterQueryForm object has no attribute cleaned_data error.

Steps to reproduce

  • Have Django 3.2.0 installed
  • Try creating a filter

Expected behaviour

You should be able to create a filter

Details

  • OS: Windows 10/Alpine Linux v3.13
  • Python version 3.7/3.8
  • Django version 3.2.0
  • django-advanced-filters version 1.3.0
  • Browser Chrome
@Nader-Blnk
Copy link

@DuSheridan Did you solve it?, I am facing the same problem

@DuSheridan
Copy link
Author

@Nader-Blnk I've side-stepped the issue by downgrading django to 3.1.3, haven't really looked into it since.

@theLastOfCats
Copy link

Looks like it's broken starting after merging this PR
django/django#13627

@vineetg3
Copy link

I'm facing the same issue, with django 3.2.2

@DavidCrediverso
Copy link

same problem :(

@tovfikur
Copy link

Same problem :(

@urfinorg
Copy link

urfinorg commented Sep 13, 2021

As i can see, this issue starting from Django 3.2. I can`t reprodusing it on 3.1.13(last version of 3.1 branch).,
ok, as first very dirty solution, we can override clean method of AdvancedFilterForm class,
inside your admin.py

from advanced_filters import forms as adv_forms
class MyAdvancedFilterForm(adv_forms.AdvancedFilterForm):
    def clean(self):
        for form in self.fields_formset:
            if not form.is_valid():
                form.cleaned_data = {'field':'id', 'DELETE': True}
        return super().clean()
class MyAdminAdvancedFiltersMixin(AdminAdvancedFiltersMixin):
    advanced_filter_form = MyAdvancedFilterForm

# as usually
@admin.register(MyModel)
class MyModelAdmin(MyAdminAdvancedFiltersMixin, admin.ModelAdmin ):
    list_display = ('__str__', 'id', 'title', .....)
    advanced_filter_fields = (
        'id',
        'title'
        ....
    )

It`s work's, almost as expected, but it's probably broke editing form... So, you can create filters, but you can't edit it.
problem of this issue: formset try validete default emty_form. This form always empty, so is_bound prorerty - False. Validation - fail, form do not create cleaned_data...

Hope, founders fix it. django-advanced-filters is really useful extension.

@hzung
Copy link

hzung commented Oct 22, 2021

@urfinorg I can't edit the filter either. Is there any way to fix it?

@hzung
Copy link

hzung commented Nov 2, 2021

I finally fix the above issue by adding these codes in the source and installing the extension by

cd django-advanced-filters
python3 setup.py install

Thanks to the code of @urfinorg

Here is the PR: https://github.com/modlinltd/django-advanced-filters/pull/153/files
I can create a new filter or update the filter now. I don't know if there is any drawback to this fix. But at least It works for now

@taut-and-yare
Copy link

This seems to be fixed in the develop branch?!
@DuSheridan any plans for a PyPI release that fixes this?

@Aref20
Copy link

Aref20 commented Jun 22, 2022

Do you fix it?

@davidfstr
Copy link

Recent maintainers @asfaltboy and @hugovk , this issue prevents the use of django-advanced-filters on Django 3.2+.

My understanding is that a fix has been merged to the develop branch but no release has been issued to PyPI with the fix. Any chance one of you could cut a release so that django-advanced-filters can be used on modern Django versions?

@hugovk
Copy link
Contributor

hugovk commented Jun 22, 2022

@davidfstr Hi! I'm not a maintainer here, just contributed a PR :)

Only @asfaltboy is listed as the PyPI maintainer https://pypi.org/project/django-advanced-filters/, hopefully he can make a release soon.

@asfaltboy
Copy link
Member

Thanks for the kind reminder, since this version contains a breaking change (dropping support for older Python/Django versions), it's released as 2.0.0 on pypi.

@DmytroLitvinov
Copy link
Contributor

Hi @asfaltboy ,

Good news. May you also take a look at related PR for that issue? #153

Maybe we can merge it and release to PyPI also?

@asfaltboy
Copy link
Member

@DmytroLitvinov we're saying the validation issue is not fixed in 2.0 ? Can you provide some more details on what used to happen and what doesn't happen now? Would it previously let you create a filter without any value in the value field, or would it raise a validation error, and now doesn't?

@DmytroLitvinov
Copy link
Contributor

Hi @asfaltboy ,
It was reported by my colleague so I just let you know about taking a look. In our case we reused library for our own needs.

@asfaltboy
Copy link
Member

I wasn't able to reproduce this particular issue as described above in 2.0. I'm going to go ahead and close the issue. If there are any concerns, please let me know. If there's still some issue, kindly provide step-by-step instructions on how to reproduce the issue. And please forgive me If I missed something obvious

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

No branches or pull requests