django admin datepicker

384 views
Skip to first unread message

sum abiut

unread,
Mar 30, 2017, 4:55:47 PM3/30/17
to django...@googlegroups.com


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>

Mike Dewhirst

unread,
Mar 30, 2017, 11:00:21 PM3/30/17
to django...@googlegroups.com
On 31/03/2017 7:55 AM, sum abiut wrote:
>
>
> 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.

What happens if you leave the widget option out altogether?
> --
> 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...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@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
> <https://groups.google.com/d/msgid/django-users/CAPCf-y7PRbbmbM%2BuSSWS7hjBqziDBWRusv7GsmikjqU%2B5hzMuw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages