date field is not rendered in template-Django

I am using a model form in app,

models.py

class Report(models.Model):
    manual_date_time = models.DateTimeField('Another time', null=True, blank=True)

modelform.py is

class ReportForm(forms.ModelForm):   
    class Meta:
        model = Report
        fields = ['incident_description','manual_date_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']

class ReportPersonForm(forms.ModelForm):
    class Meta:
        model = ReportPerson
        fields = ['name','first_aid','sick_bay','ambulance']

template is

In my template, I used the below code to render the field but field area is not shown in template.

{{ form.manual_date_time }}

views.py

def when(request):

    return render(request, 'incident/when.html',
                  {
                   'newreport_menu': True,
                 })

May I know what I did wrong?

Answers


django doesn't magically put your form in your page...

def when(request):

    form = ReportForm()

    return render(request, 'incident/when.html',
              {
               'form': form,
               'newreport_menu': True,
             })

now you have a context element called form which you can reference in your template with {{ form }}


Need Your Help

understand how reshape function forms matrix

matlab matrix reshape

let us consider following matrix for illustration

How do I add a UIview to an imageView while ensuring that the contents of the UIView are inside the it's frame?

ios swift uiview ios8 addsubview

I have a superview which contains a ImageView, a testView, and some buttons. I created a UIView which contains ImageView2 and a removebutton.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.