A DOJO problome

Status
Not open for further replies.

yimng

Cadet
Joined
Jun 21, 2013
Messages
6
I add a new Datefield to some model, but the date always invalid in the page. How can I fix this problem.
QQ截图20131015105130.png


The problem is that the post date is in format like this:"Thu Oct 16 2014 00:00:00 GMT+0800 (China Standard Time)". so the python can't parse the string to a date. how can i post the date as "10/16/2014"?
 

yimng

Cadet
Joined
Jun 21, 2013
Messages
6
In the account.models.py, add a new field to bsdUsers:
Code:
 bsdusr_expired = models.DateField(
            verbose_name=_("expired"),
            default=datetime.now()+timedelta(days=365),
            )

and the add new bsduser can't pass validation....
Please post the relevant section of code.
 

yimng

Cadet
Joined
Jun 21, 2013
Messages
6
I have fixed this problem, thank
I add a new Datefield to some model, but the date always invalid in the page. How can I fix this problem. View attachment 2903

The problem is that the post date is in format like this:"Thu Oct 16 2014 00:00:00 GMT+0800 (China Standard Time)". so the python can't parse the string to a date. how can i post the date as "10/16/2014"?
I have fixed this problem. I add code ine form init method:

Code:
DATE = re.compile(r'\w{3}\s\d{2}\s\d{4}')
            search = DATE.search(new['bsdusr_expired'])
            args[0]['bsdusr_expired'] = datetime.strptime(search.group(0), '%b %d %Y')

then the validation passed....

Thanks
 
Status
Not open for further replies.
Top