I have a form with a SplitDateTimeField:
class EventCreationForm(forms.ModelForm):
start_hosting_date_and_time = forms.SplitDateTimeField(input_date_formats=["%d-%m-%Y"], input_time_formats=["%H:%M"],
widget = forms.widgets.SplitDateTimeWidget( date_attrs = {"placeholder": "dd-mm-yyyy"},
time_attrs= {"placeholder": "TT:MM"}))
and then in my template
<!-- Hosting Date -->
<div class="form-group">
<label for="start_hosting_date_and_time"><i class="fas fa-calendar-alt"></i> Event dato</label>
{% if form.start_hosting_date_and_time.errors %}
<div class="error">
{% for error in form.start_hosting_date_and_time.errors %}
{{ error }}
{% endfor %}
</div>
{% endif %}
<div class = "start_hosting_date_and_time">
{{ form.start_hosting_date_and_time}}
</div>
</div>
now, I want to control the date/time more finegrained i.e I want to create a div for each of them. But I can’t figure out how do “index” them (and I can’t find anything in the django documentation)
I’ve tried accessing the date like {{ form.start_hosting_date_and_time.0}}
but that gives me the same widget as just {{ form.start_hosting_date_and_time}}
. I have tried various other stuff like {{ form.start_hosting_date_and_time.date}}
and such but nothing seems to work.
Any ideas (and if doable, a link to the documentation since it must be written somewhere)?