looks like you have a problem with a form : datafield   support 2 formats,
but datainput only one

Many thanks,

Serge


+380 636150445
skype: skhohlov


On Sat, Jun 15, 2013 at 2:29 PM, <[email protected]> wrote:

> view.py
>
> def when(request):
>     """"""""
>     if not report.manual_date:
>         report.manual_date = datetime.datetime.now()
>     if not report.manual_time:
>         report.manual_time = datetime.datetime.now()
>     if int(dateformat):
>         date = report.manual_date.strftime('%m/%d/%Y')
>     else:
>         date = report.manual_date.strftime('%d/%m/%Y')
>     reportform = ReportForm(instance=report,initial={'manual_date':date, 
> 'manual_time':time})
>     if request.method == 'POST':
>         reportform = ReportForm(request.POST,instance=report)
>         if reportform.is_valid():
>             report = reportform.save(commit=False)
>             report.user = request.user
>             report.save()
>             reportform = 
> ReportForm(instance=report,initial={'manual_date':date, 'manual_time':time})
>     return render_to_response('incident/when.html', {
>                       'date':date,
>                       'reportform': reportform,
>                       },
>             context_instance=RequestContext(request))
>
> forms.py
>
> DATE_INPUT_FORMAT = (
>     ('%d/%m/%Y','%m/%d/%Y'))
> class ReportForm(forms.ModelForm):
>     manual_date = forms.DateField(input_formats = DATE_INPUT_FORMAT,
>                       widget=forms.DateInput(format = 
> '%d/%m/%Y',attrs={'size':'15','id':'datepicker','readonly':'readonly'}))
>
>
> jQuery :
>
> $(function () {
>         $( "#datepicker" ).datepicker({
>             showOn: "button",
>             buttonImage: "{{ STATIC_URL 
> }}images/incident-reporter-icon-when.png",
>             dateFormat: ('dd/mm/yy'),
>             buttonImageOnly: true,
>             changeYear: true,
>             changeMonth: true
>         });
>     });
>
> 1.Date format should change depend upon the value in database,if value is
> in db,it shows the 1st format and for none ,else part is executing.
>
> 2.Formats are changing depends upon the condition.
>
> 3.I am facing problem here,if the input format is of this (%m/%d/%Y),on
> form post the value of date gets interchange and saved in database.If the
> given date is 07/06/2013 -->7th june 2013,after form post it is viewed in
> the field as 06/07/2013 -->6th july 2013.It is not working properly.
>
> 4.Since i am not sure where the problem is,that's the reason i updated
> views,forms and datepicker code.
>
> Need help to solve this issue.
>
> Thanks
>
>
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to