Django 1.8 & Django Crispy Forms: Is there a simple, easy way of implementing a Date Picker? -


there awful lot of date/datetime picker implementations out there. there integrate django , crispy forms particularly well, , how used?

i'm looking minimise development effort, maximise simplicity, , make use of django localisation.

a django/crispy standard output date field:

<input class="dateinput form-control" id="id_birth_date" name="birth_date" type="text" value="21/07/2015"> 

in model:

birth_date = models.datefield(verbose_name='d.o.b', auto_now_add=false, auto_now=false) 

thanks!

edit:

profile model:

from django.db import models  class profile(models.model):     birth_date = models.datefield(verbose_name='d.o.b', auto_now_add=false, auto_now=false) 

profile form:

from django import forms profiles.models import profile   class profileform(forms.modelform):     class meta:         model = profile         birth_date = forms.datefield(             widget=forms.textinput(                 attrs={'type': 'date'}             )         ) 

profile view:

from django.shortcuts import get_object_or_404 django.contrib.auth import get_user_model profiles.models import profile profiles.forms import profileform  user = get_user_model()  def edit(request):     profile = get_object_or_404(profile, user=request.user)     form = profileform(request.post or none, request.files or none, instance=profile)     if request.method == 'post' , form.is_valid():         form.save()     context = {         'form': form,         'page_title': 'edit profile',     }     return render(request, 'profiles/edit.html', context) 

profile edit template:

<form enctype="multipart/form-data" method="post" action=".">     {% csrf_token %}     {{ form }}     <input class='btn btn-primary' type="submit" value="submit" /> </form> 

not answer crispy forms newer browsers put in date picker long input has attribute type of date. falls category of minimal development effort.

date_field = forms.datefield(     widget=forms.textinput(              attrs={'type': 'date'}      ) )                                            

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -