python - How can I use a calendar visual widget in django form? -


i creating django application , have next problem: cannot add calendar widget works.

i have next script in html code:

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="/resources/demos/style.css"> <script> $(function() {     $( ".vdatefield" ).datepicker(); }); </script>  ...   <form id="ensaioak_bilatu" method="post" action="/farmaciapp/aukera_menua/ensaio_kontsulta/ensaio_bilaketa/" enctype="multipart/form-data">          {% csrf_token %}          {{ forma.as_p }}           <input class="btn btn-primary" type="submit" name="bilatu_ensaioak" value="bilatu"/>      </form> 

i have model of datefield type fields; , form this:

class forma(forms.modelform):   def __init__(self, *args, **kwargs):     super(forma, self).__init__(*args, **kwargs)     # making name required      self.fields['date'].required = false  class meta:     model = ensaioa 

if create object in html code directly, calendar widget works, if try use form used in html code above, doesn't work. why???

any idea fix problem???

thank much!!!

are sure date column has .vdatefield class? try adding class column:

class forma(forms.modelform):      def __init__(self, *args, **kwargs):         super(forma, self).__init__(*args, **kwargs)         # making name required         self.fields['date'].required = false         # adding .vdatefield class         self.fields['date'].widget.attrs = {'class': 'vdatefield'}      class meta:         model = ensaioa 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -