Hola,
I've set up a CalendarWidget as per the docs
https://docs.djangoproject.com/en/1.6/topics/forms/media/ and can see
correct results in the shell:
forms.py
---------
class CalendarWidget(forms.TextInput):
class Media:
css = {
'all': (settings.STATIC_URL + 'css/datepicker.css',)
}
js = (settings.STATIC_URL + 'js/bootstrap-datepicker.js',)
...
class CarrierWizardForm1(forms.Form):
part_numbers = forms.ModelChoiceField(queryset=PartNumber.objects.all())
expiry_date = forms.DateField(widget=CalendarWidget)
shell
-------
>>> from inventory import forms
>>> w = forms.CalendarWidget()
>>> print(w.media)
<link href="/static/css/datepicker.css" type="text/css" media="all"
rel="stylesheet" />
<script type="text/javascript"
src="/static/js/bootstrap-datepicker.js"></script>
>>> f = forms.CarrierWizardForm1()
>>> print(f.media)
<link href="/static/css/datepicker.css" type="text/css" media="all"
rel="stylesheet" />
<script type="text/javascript"
src="/static/js/bootstrap-datepicker.js"></script>
But in the browser I'm not seeing the new widget.
What am I doing wrong? Do I have to explicitly pull the assets into
the template in question?
Am I meant to be explicitly referring to the widget in the template?
I note that using the built in SelectDateWidget works fine:
from django.forms.extras.widgets import SelectDateWidget
class CarrierWizardForm1(forms.Form):
part_numbers = forms.ModelChoiceField(queryset=PartNumber.objects.all())
#expiry_date = forms.DateField(widget=CalendarWidget)
expiry_date = forms.DateField(widget=SelectDateWidget)
Cheers
L.
--
From this perspective it is natural that anarchism be marked by
spontaneity, differentiation, and experimentation that it be marked by
an expressed affinity with chaos, if chaos is understood to be what
lies outside or beyond the dominant game or system. Because of the
resistance to definition and categorisation, the anarchist principle
has been variously interpreted as, rather than an articulated
position, “a moral attitude, an emotional climate, or even a mood”.
This mood hangs in dramatic tension between utopian hope or dystopian
nihilism...
-----
http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos