Django admin filter by ranges of dates with calendar
Adds filtering by ranges of dates in the admin filter sidebar.
class DateFilterSpec(DateFieldFilterSpec):
"""
"""
def __init__(self, f, request, params, model, model_admin):
super(DateFilterSpec, self).__init__(f, request, params, model,
model_admin)
self.field_generic = '%s__' % self.field.name
def title(self):
title = super(DateFilterSpec, self).title()
form = DateForm(initial=self.params)
out = u"""
<style>
.calendarbox {
/*left:0 !important;*/
z-index:1100;
}
</style>
<form method="GET" action="">
<link rel="stylesheet" type="text/css" href="%(admin_media)scss/forms.css" />
<link rel="stylesheet" type="text/css" href="%(admin_media)scss/widgets.css" />
%(form_media)s
<ul>
%(form)s
<li> <input type="submit" value="%(search)s"> </li>
</ul>
</form>
""" % {'search':_('Go'),'form_media':form.media,'form':form.as_ul(),'admin_media':settings.ADMIN_MEDIA_PREFIX}
return mark_safe(title) + mark_safe(out)
https://github.com/coolchevy/django-datefilterspec
Читайте також:
- django postgresql та SCHEMA для таблиць
- Проксі моделі Django
- django custom admin
- MemcachedKeyLengthError: Key length is > 250
- django-stdimage traceback "The '%s' attribute has no file associated with it"
- Django defer, only
- Ordering related objects in Django
- django excel response
- Django yandex and google maps integration
- {% TREE %}: Дерева в django-шаблонах