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
Читайте також:
- MemcachedKeyLengthError: Key length is > 250
- django custom admin
- django-mptt деревоподібний select
- Fix Django 1.4 admin_site ForeignKeyRawIdWidget issue
- Ordering related objects in Django
- Django defer, only
- django-stdimage traceback "The '%s' attribute has no file associated with it"
- Python + CouchDB
- Django yandex and google maps integration
- Проксі моделі Django