Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django forms date picker

# Directly from GCBV with no dependencies. 
# Alternatively, you could also override the widget in a separate Form object.

from django.views.generic import CreateView
from django.contrib.admin.widgets import AdminDateWidget
from .models import MyModel

class MyModelCreateView(CreateView):
    template_name = 'form.html'
    model = MyModel
    fields = ['date_field', ...]

    def get_form(self, form_class=None):
        form = super(MyModelCreateView, self).get_form(form_class)
        form.fields['date_field'].widget = AdminDateWidget(attrs={'type': 'date'})
        return form
Source by pypi.org #
 
PREVIOUS NEXT
Tagged: #django #forms #date #picker
ADD COMMENT
Topic
Name
2+1 =