I am using the generic editing views as described in the docs (Generic editing views | Django documentation | Django). Everything works fine except I cannot figure out how to style the CreateView. UpdateView shows, eg. the date widget but CreateView does not. CreateView does not seem to respect styles passed to the form element in the associated html template. I can live without the date widget in the CreateView but need to change the text color for input elements to make it useable.
Any pointers would be much appreciated.
forms.py
class StrikeModelForm(forms.ModelForm):
class Meta:
model = Strike
fields = (
'player',
'strike_date',
'activity',
'ishard',
'comments'
)
widgets = {
'strike_date': widgets.DateInput(attrs={'type':'date'}),
'comments': Textarea(attrs={'cols': 40, 'rows': 5})
}
strike_create.html
{% extends './base.html' %}
{% block content %}
{% load crispy_forms_tags %}
<section class="body-font overflow-hidden">
<div class="px-5 py-24 mx-auto">
<div class="mx-auto justify-items-start text-left">
<div class="lg:w-1/2 lg:pr-10 lg:py-2 mb-6 lg:mb-0">
<a class="mb-2" href="{% url 'strike.list' %}">Back to strikes</a>
<hr class="mb-2" />
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<button class="border px-2 border-blue-500" type="submit">Strike!</button>
</form>
</div>
</div>
</div>
</section>
{% endblock content %}