Working with my first django application, and I have a model defined with some DateFieldsand then a ModelFormoff of that model ie
models.py
class MyModel(models.Model):
...
my_date = models.DateField('my date')
...
class MyModelForm(ModelForm):
class Meta:
model = MyModel
fields = '__all__'
views.py
def show(request):
form = MyModelForm
template_name = 'myapp/show.html'
return render(request,template_name,{'form':form})
and then in my html i use .as_pdjango to display the form for me
<form action="/show/" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
But it DateFieldshas input type text, not a date. Is there any way to change this?
source
share