feat: Use crispy form tag

This commit is contained in:
moanos [he/him] 2024-04-20 08:06:20 +02:00
parent 6d1cf9084b
commit 65a921248f
3 changed files with 19 additions and 8 deletions

View File

@ -1,13 +1,24 @@
from django import forms from django import forms
from .models import AdoptionNotice, Animal, Image, Report, ModerationAction, User from .models import AdoptionNotice, Animal, Image, Report, ModerationAction, User
from django_registration.forms import RegistrationForm from django_registration.forms import RegistrationForm
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from django.utils.translation import gettext_lazy as _
class DateInput(forms.DateInput): class DateInput(forms.DateInput):
input_type = 'date' input_type = 'date'
class AdoptionNoticeForm(forms.ModelForm): class AdoptionNoticeForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-exampleForm'
self.helper.form_class = 'card'
self.helper.form_method = 'post'
self.helper.add_input(Submit('submit', _('Submit')))
class Meta: class Meta:
model = AdoptionNotice model = AdoptionNotice
fields = ['name', "group_only", "further_information", "description", "searching_since"] fields = ['name', "group_only", "further_information", "description", "searching_since"]

View File

@ -135,8 +135,12 @@ h1 {
.btn { .btn {
border: 2px solid #4090b6; background-color: var(--primary-light-one);
background-color: #4ba3cd; color: var(--secondary-light-one);
padding: 16px;
border-radius: 8px;
border: none;
font-weight: bold;
} }
.form-button, .link-button a:link, .link-button a:visited { .form-button, .link-button a:link, .link-button a:visited {

View File

@ -11,9 +11,5 @@
Fotos hochzuladen. Fotos hochzuladen.
</p> </p>
{% endblocktranslate %} {% endblocktranslate %}
<form method="post" class="card" enctype="multipart/form-data"> {% crispy form %}
{% csrf_token %}
{{ form | crispy}}
<button type="submit">{% translate "Weiter" %}</button>
</form>
{% endblock %} {% endblock %}