title: Passing variable to a form for display in django
body: <p>views.py</p>
  
  <pre><code>def when(request):
      user = request.user
      report = Report.objects.get(user=request.user)
      reportform = ReportForm(instance=report)
  
      settings = Settings.objects.get(user=request.user)
      settingsForm = SettingsForm(instance=settings) 
   #   settings=Settings.objects.get(user=2)
      if settings.date_format == '0':
          date = report.manual_date.strftime('%d/%m/%Y')
      else:
          date = report.manual_date.strftime('%m/%d/%Y')
      if settings.time_format == '0':
          time = report.manual_time.strftime('%I:%M%p')
      else:
          time = report.manual_time.strftime('%H:%M')
      if request.method == 'POST':            
          reportform = ReportForm(instance=report,data=request.POST,initial={'manual_date': date,'manual_time': time})
          if reportform.is_valid():
              report = reportform.save(commit=False) 
              report.user = request.user
              report.save()
              return redirect('/member/media/')
  
      return render_to_response('incident/when.html',{
                    'newreport_menu': True, 
                    'form': reportform,
                     'date':date,
                     'time':time,                  
                     },
                     context_instance=RequestContext(request))
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>class ReportForm(forms.ModelForm):   
      class Meta:
          model = Report
          fields = ['incident_description','manual_date','manual_time', 'location_description',
                    'incident_followup', 'incident_followup_name_1', 'incident_followup_email_1', 
                    'incident_followup_name_2', 'incident_followup_email_2', 'phone_call_log', 
                    'notes_other','notes_firstaid','notes_risk']
      #    manual_date = forms.DateField(input_formats=['%d/%m/%Y', '%d-%m-%Y'],
       #                              widget=forms.DateInput(format="%-d/%-m/%Y"))
          widgets = {'manual_date': forms.DateInput(attrs={'size':'15','id':'datepicker',
              },format='%d/%m/%Y'),'manual_time': forms.TimeInput(attrs={'size':'8','class':'time_field', },format='%H:%M')
           }
  </code></pre>
  
  <p>How to pass the converted date and time format i.e,date and time variable to form.The format what i specified in form is displaying now,but depend on the condition on views,the time and date format should change in form field.</p>
  
  <p>Thanks</p>