modlinltd / django-advanced-filters

Add advanced filtering abilities to Django admin
https://pypi.org/project/django-advanced-filters/
MIT License
771 stars 173 forks source link

incompatibility with python 3 #6

Closed bjornpoort closed 8 years ago

bjornpoort commented 8 years ago

using latest stable django (1.8.7) and python 3.5 - not compatible at this moment? when applying any filter it returns this error:

name 'basestring' is not defined exception location: env/lib/python3.5/site-packages/advanced_filters/form_helpers.py in clean, line 29

a fix could by as mentioned here http://www.rfk.id.au/blog/entry/preparing-pyenchant-for-python-3/ "These are both errors in Python 3 since there's no such thing as 'unicode' or 'basestring'. But it's pretty simple to normalise the vocabulary between the two versions:

try: unicode = unicode except NameError:

'unicode' is undefined, must be Python 3

str = str unicode = str bytes = bytes basestring = (str,bytes) else:

'unicode' exists, must be Python 2

str = str unicode = unicode bytes = str basestring = basestring "

Not sure how to implement this (rookie python level). Someone got an idea?

asfaltboy commented 8 years ago

The latest release 1.0.1 (now also available on pypi) should resolve the issue. Please test and let us know.

bjornpoort commented 8 years ago

Works now! Very nice asfaltboy. Above issue is solved. Been testing, couple of issues came into play. You appreciate if they are raised seperately? If not, see below:

1 There is a template error when clicking on 'advanced filter l edit' after applying:

image

2 When Isnull operator is selected, it still requires a value.

image

3 When m2m is filtered, raises the following error:

image

asfaltboy commented 8 years ago

Thanks @bjornpoort! Please open issue for the 3rd case (m2m filter) with more details on how to reproduce. I've allowed myself to open the 2 first issues and close this issue as it seems resolved now.