Valid Dates in AppEngine forms (Beginner)
Posted
by codingJoe
on Stack Overflow
See other posts from Stack Overflow
or by codingJoe
Published on 2010-04-26T15:48:09Z
Indexed on
2010/04/26
16:43 UTC
Read the original article
Hit count: 329
google-app-engine
|django
In AppEngine, I have a form that prompts a user for a date. The problem is that when the clicks enter there is an error: "Enter a Valid Date"
How do I make my Form accept (for example) %d-%b-%Y
as the date format?
Is there a more elegant way to accomplish this?
# Model and Forms
class Task(db.Model):
name=db.StringProperty()
due=db.DateProperty()
class TaskForm(djangoforms.ModelForm):
class Meta:
model = Task
# my get function has the following.
# using "now" for example. Could just as well be next Friday.
tmStart = datetime.now()
form = TaskForm(initial={'due': tmStart.strftime("%d-%b-%Y")})
template_values = {'form': form }
© Stack Overflow or respective owner