From cf5c9da50ed0d57351e9978e3496e75b11c62f0f Mon Sep 17 00:00:00 2001 From: ks Date: Thu, 16 Aug 2018 17:23:28 +0300 Subject: [PATCH 1/2] hotfix for Django 2.0 --- grappelli_filters/admin.py | 8 +++----- grappelli_filters/filters.py | 8 ++++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/grappelli_filters/admin.py b/grappelli_filters/admin.py index 1c7dad0..90c0923 100644 --- a/grappelli_filters/admin.py +++ b/grappelli_filters/admin.py @@ -1,11 +1,9 @@ from django.contrib import admin -from django.templatetags.static import static -class FiltersMixin( admin.ModelAdmin ): - +class FiltersMixin(admin.ModelAdmin): class Media: - js = (static('grappelli_filters/filter.js'),) + js = ('grappelli_filters/filter.js', ) css = { - 'all': (static('grappelli_filters/filter.css'),), + 'all': ('grappelli_filters/filter.css', ) } diff --git a/grappelli_filters/filters.py b/grappelli_filters/filters.py index c36bad6..321f1bb 100644 --- a/grappelli_filters/filters.py +++ b/grappelli_filters/filters.py @@ -1,9 +1,7 @@ from django.contrib import admin -from django.contrib.contenttypes.models import ContentType class AbstractFieldListFilter(admin.FieldListFilter): - tempalte = '' filter_parameter = None url_parameter = None @@ -57,12 +55,14 @@ def get_parameter_name(self, field_path): return u'{0}__id__exact'.format(field_path) def __init__(self, field, request, params, model, model_admin, field_path): + from django.contrib.contenttypes.models import ContentType + super(RelatedAutocompleteFilter, self).__init__(field, request, params, model, model_admin, field_path) if self.model: content_type = ContentType.objects.get_for_model(self.model) else: - content_type = ContentType.objects.get_for_model(field.rel.to) - self.grappelli_trick = u'/{app_label}/{model_name}/'.format( + content_type = ContentType.objects.get_for_model(field.remote_field.model) + self.grappelli_trick = u'/{app_label}/{model_name}/?_to_field=id'.format( app_label=content_type.app_label, model_name=content_type.model ) From 23bd0c0144be879c41e4d2279818b91aead0533b Mon Sep 17 00:00:00 2001 From: ks Date: Fri, 21 Sep 2018 12:23:39 +0300 Subject: [PATCH 2/2] little changes --- dist/django-grappelli-filters-0.2.tar.gz | Bin 7117 -> 0 bytes grappelli_filters/__init__.py | 2 -- grappelli_filters/filters.py | 13 ++++--------- setup.py | 12 ++++++++---- 4 files changed, 12 insertions(+), 15 deletions(-) delete mode 100644 dist/django-grappelli-filters-0.2.tar.gz diff --git a/dist/django-grappelli-filters-0.2.tar.gz b/dist/django-grappelli-filters-0.2.tar.gz deleted file mode 100644 index a354e3ad71363cd5018404a4633c005e068d454e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7117 zcmai2Ran%4vn8cNPz06^=@Jm>1tbM&sRg9F1?dIp2BllNySuxQTwtZUyY~0@e;@9{ zeYx{=zBBX9Jk6YM4s`@3rjL%8ItpNF4n#!$Z9FrGP6CI=P}Xm!`5Sgq z7rx)?H?4<0u{o}a_n%5Go$ z#sj#5w_$zMY8zg(ok!0*5NeQf{J5I=JB4((rhNN631!s%7R7{_zC?#=tI#TL!QaNcW%?2icHzf1 zjv;t;@EXx-d0)o?fdoa zO)}BWnm?`yjq@zQ6Ve=B(7Mwat^<2e*Ng-)QBFvXb*E+QJi_g<$#;=voJ8=$3eeCz zw@8=biL=Iw?!02#xhQT;-1VXCw7!%65ti3+OLb;dzu~1@)}ceHqD$ZxXsS2(W&Vk#o%xpS>LvA}m6)6xz-fSgQF1qSLZU8Qg*o zyoZfHi;f|75C)Hg1~{?5d*AP5NQ>GxkfZ1OF4`KcH4@zVizwh5AMw%=I#hNSXKTny z-ueAFl`S7gPAZr2!LY37cBUZ1wg>(BX4+b$ZaJYCmtF8x6E9hpdW2l#@BY+n#kEr}pl5l}t2PCLrQPn(mqH>pI zl7U@VTRau+d>4xxj^Ar6T>i#CMX#_(pWf!?o=J?JN~Dt;3`yLMXpZ#}a#plN6}<@J z>mpb}5Omyol93lZ-@*Vx{nGN!cTk)9k~%=xU;n_SWyfX|F8N#Pvi0+bwa(J4%(slO z89c@wbVgO(Zc8+u6IZnbS5!U6J!71Y^8~A&<#_CA-jr&zsbcTgw}V7;Mx)>ReXH`h z&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dEuCOO6?eghp6uKM$T-gaAH@i;YSHe^K;C^8i4PX{+3RFafe-fd zIP)}Og1V;~AQgvAvj>I9BerN0ZBgDSE7`xs(j|6(%hipznSWWi^=T^0g>Q1J-DLFSY28Mj+6u9%0(`*{U86QM~Zd$K}fJbpXf23lHkF3hTij^ z4;$LZh$f0}zmdTrG$$`Qg=c-uEY&M~>}1d%k$d7;P2bb-X}@`A#{Ep}ug%d}=X_Ae zZYRo`Zv>xzOMpDXl8~ca?6PIxop6^1QtA&Ld`>Xy7u?I2f?M>fAA*pI1M>7m6yE4s zT%yR*{nnbWPrG=^{;rVivBMxIogu*gq?wW>7+g`&PhV#@xVQfORiTZl0rTKs|C{5R u?v+r*t2bX${pczVUOIKZxTqQYrwIR5h<|ta{{bd<;;}usib!WjNdEyvT|FTH diff --git a/grappelli_filters/__init__.py b/grappelli_filters/__init__.py index 60185d0..e69de29 100644 --- a/grappelli_filters/__init__.py +++ b/grappelli_filters/__init__.py @@ -1,2 +0,0 @@ -from .filters import RelatedAutocompleteFilter, SearchFilter, SearchFilterC -from .admin import FiltersMixin diff --git a/grappelli_filters/filters.py b/grappelli_filters/filters.py index 321f1bb..bb8db37 100644 --- a/grappelli_filters/filters.py +++ b/grappelli_filters/filters.py @@ -19,10 +19,6 @@ def has_output(self): """ Whether to show filter """ return True - def lookups(self, request, model_admin): - """ Not using lookups """ - return () - def choices(self, cl): """ Not used, but required by admin_list_filter template tag """ return () @@ -52,7 +48,7 @@ class RelatedAutocompleteFilter(AbstractFieldListFilter): def get_parameter_name(self, field_path): if self.url_parameter: field_path = self.url_parameter - return u'{0}__id__exact'.format(field_path) + return '{0}__id__exact'.format(field_path) def __init__(self, field, request, params, model, model_admin, field_path): from django.contrib.contenttypes.models import ContentType @@ -62,7 +58,7 @@ def __init__(self, field, request, params, model, model_admin, field_path): content_type = ContentType.objects.get_for_model(self.model) else: content_type = ContentType.objects.get_for_model(field.remote_field.model) - self.grappelli_trick = u'/{app_label}/{model_name}/?_to_field=id'.format( + self.grappelli_trick = '/{app_label}/{model_name}/?_to_field=id'.format( app_label=content_type.app_label, model_name=content_type.model ) @@ -72,12 +68,11 @@ class SearchFilter(AbstractFieldListFilter): template = 'grappelli_filters/search.html' def get_parameter_name(self, field_path): - return u'{0}__icontains'.format(field_path) + return '{0}__icontains'.format(field_path) class SearchFilterC(SearchFilter): """ Case-sensitive serach filter """ def get_parameter_name(self, field_path): - return u'{0}__contains'.format(field_path) - + return '{0}__contains'.format(field_path) diff --git a/setup.py b/setup.py index 224b7c0..3da1199 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ import os from setuptools import setup -README = open(os.path.join(os.path.dirname(__file__), 'README.rst'), encoding='utf-8').read() +README = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read() # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) @@ -21,13 +21,17 @@ classifiers=[ 'Environment :: Web Environment', 'Framework :: Django', + 'Framework :: Django :: 1.11', + 'Framework :: Django :: 2.0', + 'Framework :: Django :: 2.1', 'Intended Audience :: Developers', 'License :: Freeware', 'Operating System :: OS Independent', 'Programming Language :: Python', - # Replace these appropriately if you are stuck on Python 2. - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ],