shamanu4 / dal_admin_filters Goto Github PK
View Code? Open in Web Editor NEWDjango autocomplete light filters for django admin
License: MIT License
Django autocomplete light filters for django admin
License: MIT License
When I use Many2many field in ListView that time it apply the filter only one selection. Multiselect does not work with autocomplete in ListView. Work fine with FormView.
hello,
I installed dal_admin_filters with
pipenv install dal_admin_filters
When settings.py includes:
...
INSTALLED_APPS = [
'voiptrunk.apps.VoiptrunkConfig',
'phonenumber_field',
'django_tables2',
'dal',
'dal_select2',
'dal_admin_filters',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
then Django's server shows:
ImportError: No module named 'six'
Commenting out line 'dal_admin_filters', in settings.py remove the above error.
Thoughts ?
Following along and implementing the example I get "'NoneType' object is not subscriptable".
https://github.com/yourlabs/django-autocomplete-light/blob/master/src/dal/widgets.py#L133
expects attrs to have an 'id' key. It defaults to None and doesn't check before calling the 'id' key.
https://github.com/shamanu4/dal_admin_filters/blob/master/dal_admin_filters/__init__.py#L47
doesn't explicitly set attrs. I haven't looked too much into it. For me everything works if I set a bogus 'id'.
self.rendered_widget = field.widget.render(
name=self.parameter_name,
value=self.used_parameters.get(self.parameter_name, ''),
attrs={'id': 1'},
)
But it of course it is not really the way to go.
Is there a way to pass in a value from a different filter so that we can only display the subset of values? For example I have Publishers which contain Series and I'd like to only show the series that are available within a particular publisher if there is a filter set for publisher.
I think that this might be possible using DAL's forward mechanics, but I have no idea how I would implement that with this module.
INSTALLED_APPS = (
# django apps
"django.contrib.sites",
"dal", # these two need to be before contrib.admin
"dal_select2", # these two need to be before contrib.admin
"dal_queryset_sequence",
'dal_admin_filters',
# 'grappelli',
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.humanize",
# 3rd party apps
"rest_framework",
"rest_framework.authtoken",
"rest_framework_swagger",
"solo",
"imagekit",
"django_extensions",
"corsheaders",
"django_nose",
"taggit",
"taggit_labels",
"simple_history",
"el_pagination",
"user_messages", # Add on for django.contrib.messages with offline messaging support
# 'django_messages',
# 'djcelery_email',
"viewflow",
# 'djcelery',
"storages",
# 'simple_email_confirmation',
# 'djoser',
"dbtemplates",
"jsoneditor",
"adminsortable2",
"crispy_forms",
"django_tables2",
"django_tables2_column_shifter",
"admin_display_fields_settings",
"bootstrap3",
"notifications",
"rangefilter",
"django_filters",
"django_celery_beat",
"oauth2_provider",
"social_django",
"rest_framework_social_oauth2",
"knox",
"admin_numeric_filter",
"admin_totals",
# 'django_celery_results',
'import_export',
'mptt',]
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x110b3ac80>
Traceback (most recent call last):
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/dal_admin_filters/__init__.py", line 2, in <module>
from dal import autocomplete
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/dal/autocomplete.py", line 57, in <module>
from dal_queryset_sequence.fields import (
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/dal_queryset_sequence/fields.py", line 3, in <module>
from dal_contenttypes.fields import (
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/dal_contenttypes/fields.py", line 3, in <module>
from django.contrib.contenttypes.models import ContentType
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/contrib/contenttypes/models.py", line 134, in <module>
class ContentType(models.Model):
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/db/models/base.py", line 87, in __new__
app_config = apps.get_containing_app_config(module)
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/apps/registry.py", line 249, in get_containing_app_config
self.check_apps_ready()
File "/Users/somghosh/.virtualenvs/xenia371/lib/python3.7/site-packages/django/apps/registry.py", line 132, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
When I use the filter as horizontal, I see the annoying list bullet and have no access to remove it. Why is the list behavior exists anyway? It looks good in either side-filter and horizontal-filter without the list anyway.
After upgrading to django 2.2.2 dal_admin_filters
stop working. I am think this is cause of https://docs.djangoproject.com/en/2.2/releases/2.2.2/#patched-bundled-jquery-for-cve-2019-11358-prototype-pollution this CVE fix in jQuery.
Django 2.1.9 also has this CVE patch, but all works fine.
'NoneType' object has no attribute 'getitem'
in
dal/widgets.py in render, line 130
class OlaGruppoDiStudioFilter(AutocompleteFilter):
title = 'Gruppo di studio'
parameter_name = 'ola_gruppo_di_studio'
autocomplete_url = 'ola_gruppo-autocomplete'
class OlaGruppoDiStudioAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
if not self.request.user.is_authenticated():
return OlaGruppoDiStudio.objects.none()
qs = OlaGruppoDiStudio.objects.all()
if self.q:
qs = qs.filter(
Q(nome__istartswith=self.q) |
Q(ola_instructor__cognome__istartswith=self.q)|
Q(ola_instructor__nome__istartswith=self.q)
)
return qs.order_by('nome')
I tested it in two different apps, with two different models schema and parameter name.
Is it caused by some Null value in FK ?
If any news please let me know, I'd like to use this django app widely in my projects
I would like to send some field in forward arguments like django autocomplete light.
I tried sending them but could not succeed.
Any Idea ?
If I set a datetime or a date filter as frst selection
/?creation_date__gte=2017-03-08+00%3A00%3A00%2B01%3A00&creation_date__lt=2017-03-16+00%3A00%3A00%2B01%3A00
then if I select a dal admin filters of mine the new window location is:
/?=undefined&creation_date__gte=15%2F03%2F2017&creation_date__lte=15%2F03%2F2017&tipo_marketing=3
the erroneous "/?=undefined&" drive the window location in a new url with "?e=1" and all the previosly selected filters removed.
This happens only if a datetime filter preceeds a dal filter, if other sequence of filter appended in url this bug will not be raised.
Actually tested on two different Django platforms
Great package!
I just installed it and got the error that get_forward is not defined ...
I added 'autocomplete_light/forward.js',
to the Autocomplete -> Media -> js and it started working.
If in a model is used another primary_key label, different from the classical id name, it should be better use %s__pk__exact instead of %s__id__exact.
I made this change in my fork but I also cleaned the demo-app and the most of dependencies in requirements, so I cannot do a pull request. Just this, in
dal_admin_filters/__init__.py
def queryset(self, request, queryset):
if self.value():
lookup = "%s__id__exact" % self.parameter_name
return queryset.filter(**{lookup: self.value()})
else:
return queryset
became:
def queryset(self, request, queryset):
if self.value():
lookup = "%s__pk__exact" % self.parameter_name
return queryset.filter(**{lookup: self.value()})
else:
return queryset
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.