Answer the question
In order to leave comments, you need to log in
How to use the calendar from the admin panel in the usual form?
Subject, Django 2.0.
Googled mainly on old versions of django, which I googled on the new one doesn't work..
( https://stackoverflow.com/questions/12449603/integ... )
Answer the question
In order to leave comments, you need to log in
forms.py
from django import forms
from django.contrib.admin import widgets
class SomeForm(forms.Form):
some_field = forms.SplitDateTimeField(label='Some field',
input_date_formats=['%d.%m.%Y'],
input_time_formats=['%H:%M:%S'],
widget=widgets.AdminSplitDateTime())
class Media:
css = {
'all': (
'/static/admin/css/widgets.css',
)
}
js = [
'/admin/jsi18n/',
'/static/admin/js/core.js',
]
<script type="text/javascript">window.__admin_media_prefix__ = "{% static 'admin/' %}";</script>
{{ form.media }}
<form action="{% url 'some_url' %}" method="post">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" value="Submit">
</form>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question