Django-lomakkeen päivämäärävalitsimen suurin ongelma on, että se ei ole kovin käyttäjäystävällinen. Eri vaihtoehtoja on vaikea löytää ja käyttää, eikä ole selvää, kuinka poimijaa käytetään yhdessä muiden Django-sivuston osien kanssa.
I am trying to use a date picker in my Django form. I have tried using the following code:
<code>{{ form.date_of_birth }}
</code>
But this does not work. Can anyone help?
A:
You need to add <code>class="vDateField"</code> to your field in order for the jQuery UI DatePicker widget to be applied. For example, if you have a field named <code>date_of_birth</code>, then you would do something like this: <code>{{ form.date_of_birth|add_class:"vDateField" }}</code>. You can also add this class directly in your model's Meta class, like so: <code>Meta: fields = ('date_of_birth', ) widgets = {'date_of': forms.TextInput(attrs={'class': 'vDateField'})}</code>.
Lomakkeet
Lomakkeet ovat tehokas työkalu Djangossa. Niiden avulla voit kerätä tietoja käyttäjiltäsi ja tallentaa ne tietokantaan. Lomakkeiden avulla voit myös luoda mukautettuja lomakkeita, mikä voi tehdä tietojen lähettämisestä tietokantaan paljon helpompaa.
Treffit Djangossa
Djangossa päivämäärä on päivämäärä-aikaobjekti. Päivämäärä voi olla joko yksinkertainen datetime-objekti tai DateTime-luokan esiintymä.