django-advanced-filters icon indicating copy to clipboard operation
django-advanced-filters copied to clipboard

'AdvancedFilterQueryForm' object has no attribute 'cleaned_data'

Open DuSheridan opened this issue 3 years ago • 15 comments

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

DuSheridan avatar Apr 26 '21 08:04 DuSheridan

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

Nader-Blnk avatar May 18 '21 10:05 Nader-Blnk

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

DuSheridan avatar May 18 '21 10:05 DuSheridan

Looks like it's broken starting after merging this PR https://github.com/django/django/pull/13627

theLastOfCats avatar Jul 12 '21 16:07 theLastOfCats

I'm facing the same issue, with django 3.2.2

vineetg3 avatar Aug 10 '21 16:08 vineetg3

same problem :(

DavidCrediverso avatar Aug 31 '21 04:08 DavidCrediverso

Same problem :(

tovfikur avatar Sep 12 '21 12:09 tovfikur

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.

urfinorg avatar Sep 13 '21 08:09 urfinorg

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

hzung avatar Oct 22 '21 12:10 hzung

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

hzung avatar Nov 02 '21 11:11 hzung

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

taut-and-yare avatar Feb 18 '22 14:02 taut-and-yare

Do you fix it?

Aref20 avatar Jun 22 '22 08:06 Aref20

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?

davidfstr avatar Jun 22 '22 12:06 davidfstr

@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.

hugovk avatar Jun 22 '22 13:06 hugovk

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.

asfaltboy avatar Jun 27 '22 08:06 asfaltboy

Hi @asfaltboy ,

Good news. May you also take a look at related PR for that issue? https://github.com/modlinltd/django-advanced-filters/pull/153

Maybe we can merge it and release to PyPI also?

DmytroLitvinov avatar Jun 27 '22 11:06 DmytroLitvinov

@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?

asfaltboy avatar Sep 25 '22 09:09 asfaltboy

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.

DmytroLitvinov avatar Sep 26 '22 03:09 DmytroLitvinov

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

asfaltboy avatar Oct 08 '22 18:10 asfaltboy