When using DateTimeField
in ModelForm
s, they look like text fields. How can I make them look like in the admin? (When I go to the admin and add a show I see the fields as date fields)
# models.py
class Show(models.Model):
...
start_time = models.DateTimeField("Event Time")
sale_end_time = models.DateTimeField("Sale End Time")
class ShowForm(ModelForm):
class Meta:
model = Show
# views.py
def createshow(request):
if request.method == 'POST':
form = ShowForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/showsaved')
else:
form = ShowForm()
return render(request, 'BizCreateShow.html', {'ShowForm' : form})
In the template:
<form class="form-horizontal well" action="" method="post">
{% csrf_token %}
{{ ShowForm }} </br>
<input type="submit" value="Submit">
</form>