<div id="div_id_datetime_field" class="field-wrapper mb-3">
<label for="id_datetime_field" class="label-class block text-gray-900 text-sm mb-2">
Datetime field<span class="asteriskField">*</span>
</label>
<div>
<input
data-controller="flatpickr"
data-flatpickr-enable-time="true"
type="text"
name="datetime_field"
value="2024-11-21 11:26:20"
class=" bg-white focus:outline-none border border-gray-300 rounded-lg py-2 px-4 block w-full appearance-none leading-normal text-gray-700" required id="id_datetime_field"
>
</div>
</div>
def pick_datetime(self, **kwargs):
class TestForm(forms.Form):
datetime_field = forms.DateTimeField(
initial=timezone.now,
widget=HammerDateTimeWidget,
)
form = TestForm()
template = Template(
"""
{% load formify %}
{% render_field form.datetime_field %}
""",
)
return template.render(Context({"form": form}))