I have a model that has a couple of date fields. I am using the CreateView along with a template. In the template, I am doing fairly standard code
{% extends 'instructor_base.html' %}
{% load crispy_forms_tags %}
{% block title %}
New Section
{% endblock %}
{% block content %}
<h1>New Section</h1>
<form method="post">
{% csrf_token %}
{{ form|crispy }}
<button class="btn btn-success ml-2" type="submit">Save</button>
</form>
{% endblock %}
However, when the form displays, the two date fields in the model are displayed as text boxes in the form. I would like them to display as date type. After several hours of going through documentation and tutorial sites, I can not figure out how to accomplish this. Everything I find is on how to override CreateView itself and not the form that goes with it. Any help with this would be greatly appreciated.
question from:
https://stackoverflow.com/questions/65652203/how-to-modify-the-form-field-types-in-the-django-createview-form 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…