Thursday, March 30, 2017

django admin datepicker



Hi,
i am trying to use django admin datepicker on my custom form to have it show on two fields  but when i run the app it only showing on one field, the start_date but not showing on end_date. can some please point me to the right direction.

here is my quote.

models.py

class stafleave(models.Model):
    first_name=models.CharField(max_length=45)
    last_name=models.CharField(max_length=45)
   leave_type=models.CharField(max_length=45,choices=leave)
    start_date=models.DateField()
    end_date=models.DateField()
    Total_working_Hours=models.IntegerField()
    username =models.ForeignKey(User


forms.py

class leaveform(forms.ModelForm):
    start_date = forms.DateField(widget=widgets.AdminDateWidget)
    end_date = forms.DateField(widget=widgets.AdminDateWidget)

    class Meta:
        model=stafleave




template.html

<html>


<head>


<!-- Datepicker-->


<script type="text/javascript" src="/admin/jsi18n/"></script>

<script type="text/javascript" src="/static/admin/js/core.js"></script>

<script type="text/javascript" src="/admin_media/js/admin/RelatedObjectLookups.js"></script>
{{ form.media }}

  
    <!--End Datepicker--


</head>

<body>
 

<form action="" method="post">{%csrf_token%}
<table>
{{form.as_table}}

</table>
<br>
<input type="submit" name="submit" value="Apply for Leave" >
 

</form>
</div>



</body>

</html>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y7PRbbmbM%2BuSSWS7hjBqziDBWRusv7GsmikjqU%2B5hzMuw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment