Closed vanschelven closed 3 years ago
Similar to #21 but with a different cause (in fact: #21's solution might be the cause).
When the filter's _get_form_class is executed twice in the process of constructing a single form, the required JS is not produced, which leads to
_get_form_class
jQuery.Deferred exception: DateTimeShortcuts is not defined
Code to reproduce:
@admin.register(Foo) class FooAdmin(models.ModelAdmin): def get_changelist_instance(self, request): cl = super().get_changelist_instance(request) q = cl.get_queryset(request) return cl list_filter = [ ('bar', DateRangeFilter), ]
The reason you might want to do the above for the curious.
django==2.2.20 django-admin-rangefilter==0.7.0
The workaround for now has been to add request.DJANGO_RANGEFILTER_ADMIN_JS_SET = False right before the get_queryset call, but this is less than optimal.
request.DJANGO_RANGEFILTER_ADMIN_JS_SET = False
get_queryset
Some random thoughts from under the proverbial shower:
Thx, fixed on 0.8.0 version
Awesome, I'll check it out next week!
Indeed 0.8.1 fixes the problem I was experiencing, many thanks!
0.8.1
Similar to #21 but with a different cause (in fact: #21's solution might be the cause).
When the filter's
_get_form_class
is executed twice in the process of constructing a single form, the required JS is not produced, which leads tojQuery.Deferred exception: DateTimeShortcuts is not defined
in the JS consoleCode to reproduce:
The reason you might want to do the above for the curious.
The workaround for now has been to add
request.DJANGO_RANGEFILTER_ADMIN_JS_SET = False
right before theget_queryset
call, but this is less than optimal.