I'm trying to use the admin datepicker in my own django forms.
Roughly following the discussion here : http://www.mail-archive.com/[email protected]/msg72138.html
I've
a) In my forms.py included the line
from django.contrib.admin import widgets
b) and used the widget like this :
date = forms.DateTimeField(widget=widgets.AdminDateWidget())
c) And in my actual template I've added :
{{form.media}}
To include the js / styles etc.
However, when I try to view my form I get no nice widget; just an ordinary text box. And the Firefox javascript error console shows me :
gettext is not defined in calendar.js (line 26)
and
addEvent is not defined in DateTimeShortcuts.js (line 254)
Any suggestions? Is this a bug in Django's own javascript library?
Update : Basically, need to include the core and (or fake) the i18lization
Update 2 : Carl points out this is pretty much a duplicate of Using Django time/date widgets in custom form (although starting from a different position)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…