Login

Frontend admin date picker widget

Author:
t_rybik
Posted:
April 16, 2010
Language:
Python
Version:
1.1
Tags:
date widget
Score:
1 (after 1 ratings)

This is just a AdminDateWidget with missing JSs added. Don't forget to call {{ from.media }} in template.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from django.conf import settings
from django.contrib.admin.widgets import AdminDateWidget

I18NJS_URL = getattr(settings, 'I18NJS_URL', "i18njs/")
class Date(AdminDateWidget):
    '''
    Wrapper for the AdminDateWidget with missing media. You also have to add:

        (r'^%s' % I18JS_URL, 'django.views.i18n.javascript_catalog')

    to your site's main urls.py.
    '''
    class Media:
        # JSs have to be included in right order, thus:
        extend = False
        js = ("/%s" % I18NJS_URL, settings.ADMIN_MEDIA_PREFIX + "js/core.js",) +\
            AdminDateWidget.Media.js

        # extract approriative content from below CSS if you prefer
        css = {
            'screen': (settings.ADMIN_MEDIA_PREFIX + 'css/forms.css',
                       settings.ADMIN_MEDIA_PREFIX + 'css/global.css',
                       settings.ADMIN_MEDIA_PREFIX + 'css/base.css',
                       ),
        }

More like this

  1. Month / Year dropdown widget by gregb 5 years, 10 months ago
  2. Hidden Date Display Widget for Admin by andrew.schoen 5 years, 11 months ago
  3. Creating custom time entries in Django Date widget by adiq 1 year, 1 month ago
  4. SelectDateWidget with format: day, month, year by zenx 5 years, 6 months ago
  5. SelectTimeWidget by bradmontgomery 6 years, 7 months ago

Comments

muhdazwa (on December 20, 2010):

I like this snippet. Thank you :)

#

Please login first before commenting.