Issue
I want to understand Django form.
<div class="form-group">
<label for="deadline">Deadline</label>
<input
type="datetime-local"
class="form-control"
id="deadline"
aria-describedby="deadlineHelp"
placeholder="Enter when deadline"
/>
</div>
I want to create this field with Django. But
<form action="" method="post">{% csrf_token %} {{form.as_p}}</form>
to create a simple lines. And if I fix forms.py like
class Create(forms.ModelForm):
class Meta:
model = Task
fields = ('deadline_task',)
widgets = {
'deadline_task': forms.DateTimeInput(),
}
It not working.
<p><label for="id_deadline_task">Deadline task:</label> <input
type="text" name="deadline_task" id="id_deadline_task"></p>
I just want <input type="datetime-local"
- It convenient to select a date.
Thank you.
P.S. Django 1.11
Solution
I had exactly the same issue and solved it this way:
widgets = {
'request_date': DateTimeInput(attrs={'type': 'datetime-local'}),
}
Answered By - Robson
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.