Improve form widgets

This commit is contained in:
Jean-Marie Favreau 2023-11-09 21:25:07 +01:00
parent 0f9252173c
commit 5b439d88b0
4 changed files with 36 additions and 3 deletions

View File

@ -298,3 +298,7 @@ article#filters {
}
}
.helptext {
font-size: 80%;
opacity: 0.7;
}

View File

@ -2,12 +2,21 @@
{% block title %}Proposer un événement{% endblock %}
{% block entete_header %}
<script src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script src="/static/admin/js/jquery.init.js"></script>
<link href="/static/css/django_better_admin_arrayfield.min.css" type="text/css" media="all" rel="stylesheet">
<script src="/static/js/django_better_admin_arrayfield.min.js"></script>
{% endblock %}
{% block content %}
<h1>Proposer un événement</h1>
<form method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Enregistrer">
</form>
{% endblock %}

View File

@ -2,9 +2,16 @@
{% block title %}Éditer {{ object.title }}{% endblock %}
{% block entete_header %}
<script src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script src="/static/admin/js/jquery.init.js"></script>
<link href="/static/css/django_better_admin_arrayfield.min.css" type="text/css" media="all" rel="stylesheet">
<script src="/static/js/django_better_admin_arrayfield.min.js"></script>
{% endblock %}
{% block content %}
<h1>Édition de l'événement {{ object.title }} ({{ object.start_day }})</h1>
<form method="post">{% csrf_token %}

View File

@ -285,16 +285,29 @@ def tag_list(request):
return render(request, 'agenda_culturel/tags.html', context)
class EventCreateView(CreateView):
class EventForm(forms.ModelForm):
class Meta:
model = Event
fields = '__all__'
widgets = {
'start_day': forms.TextInput(attrs={'type': 'date'}),
'start_time': forms.TextInput(attrs={'type': 'time'}),
'end_day': forms.TextInput(attrs={'type': 'date'}),
'end_time': forms.TextInput(attrs={'type': 'time'}),
}
class EventCreateView(CreateView):
model = Event
form_class = EventForm
template_name_suffix = "_form"
template_name_suffix = "_create_form"
class EventUpdateView(LoginRequiredMixin, UpdateView):
model = Event
fields = '__all__'
form_class = EventForm
class EventDeleteView(LoginRequiredMixin, DeleteView):