I am using SelectDateWidget
widget for entering date in the form field. But I want it to show the current date by default. How can I do that?
model.py
bdate = models.DateField(default=datetime.date.today())
This is giving error. can anyone tell the correct way to do that?
Also, my in template
{{ form.bdate }}
when I use the above mentioned line in my template it displays like this -- -- -- but I want something like this month date year. how can i do this?
My form is:
widgets = {
'bdate' : SelectDateWidget(),
}
Using Django 1.3 the following worked for me:
The keyword is
initial
notdefault
.There was similar problem here
Try tu use
default=datetime.date.today
orauto_now_add=True