0

In django 1.6.5 I want to use AdminSplitDateTime widget in a custom form. this is what I've done so far:

#forms.py
class MyForm(forms.Form):
    ...
    pub = forms.DateTimeField(label="pub", widget=widgets.AdminSplitDateTime())

and in the template I have:

#mytemplate.html
...
<form method="post" action=".">
    {% csrf_token %}
    <table id="form_table">
        {{ form.as_table }}
    </table>
    <input  type="submit" value='{% trans "Send" %}' />
</form>

but when I open the page, date and time shortcuts beside the widgets (today and now) are not rendered. at first I thought maybe I'm not including right css and js, so I checked a regular admin page which renders the widget correctly and added all the css and js needed, but nothing heppend.

so what may be the problem?

VahidM
  • 287
  • 1
  • 2
  • 14
  • Are you including the "/admin/jsi18n/" script as well? Are there any errors in the browser's developer tools console? – Daniel Roseman Aug 12 '14 at 12:01
  • @DanielRoseman, yes I am including it. and I'm using firebug for debugging the page, and I see no errors. – VahidM Aug 12 '14 at 12:04
  • Shouldn't the widget be: `SplitDateTimeWidget()` ?? https://docs.djangoproject.com/en/1.6/ref/forms/widgets/#splitdatetimewidget – petkostas Aug 12 '14 at 12:23
  • @petkostas, I've tried that, I think thats a little different widget, but it still has the same problem with shortcuts. – VahidM Aug 12 '14 at 12:33
  • Ok didn't know, are you widget assets loaded correctly? (css, js) can you see them in firebug? – petkostas Aug 12 '14 at 12:38
  • Possible duplicate: http://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form – karthikr Aug 12 '14 at 12:40
  • @petkostas, I have included a bunch of `css` and `js` from statics that I thought is needed for this widget, but I'm not sure if I'm missing something. can you say exactly what am I supposed to include? – VahidM Aug 12 '14 at 12:41
  • See here https://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form?noredirect=1&lq=1 – Gordon Wrigley Apr 22 '20 at 14:12

0 Answers0