K
K
Karina2014-05-15 17:34:58
Django
Karina, 2014-05-15 17:34:58

Django. How to add a widget for a form where you need to enter the date?

What is: while a small database on sqlite3 and a field in it:
birthdate = models.DateField(null=True)
We need to do "something beautiful". Ideally: there should be three rectangles (for the month, date and years) with inverted triangles inside, by clicking on which you can select the date of birth. You probably need jQuery. Or I don't know.
What can be read? And thanks to everyone for the replies.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cyril, 2014-05-16
@aeHarkonnen

This is in the standard django tools, here is a part of my code with a change in user data, the date of birth is just changing there:
views:

class UserUpdateView(LoggedInMixin, UpdateView):
    model = User
    context_object_name = 'user_object'
    template_name = 'basics/profile_update.html'
    form_class = UserUpdateForm

forms:
class UserUpdateForm(ModelForm):
    class Meta:
        model = User
        fields = ('avatar', 'birthday', 'sex', 'first_name', 'last_name', 'email')
        widgets = {
            'birthday': SelectDateWidget(years=range(1940, 2014))
        }

C
Crash, 2014-05-15
@Bandicoot

You make a selection from the database, then translate the date into a readable format, then you can add effects and styles using JQuery and CSS

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question