Hi,I have created django forms and the logic is fine, and I have created the HTML page to show the form fields. I have attached the screenshot for the reference. The problem I am facing two issues as below:- 1) to integrate the django form fields in the HTML page through Jinja. HTML file:{% load static %} {% block content %}
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css";> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js";></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js";></script> <title>Profile Page</title> </head> <body style="background-color:orange;text-align:justify"> <nav class="navbar navbar-inverse"> <ul class="nav navbar-nav"> <li><a href="#">contact</a></li> <li><a href="#">Sign Up</a></li> <li><a href="#">Log in</a></li> </ul> </nav> <form method="post" enctype="multipart/form-data"> {% csrf_token %} <div style="margin:10px"> <label for="img"><b>Profile Photo:</b></label> <input type="file" id="img" name="img" accept="image/*"> </div> <br><br> <div style="margin:10px"> <label><b>DOB:</b></label> <input type="datetime-local" name="dob" min="1950-01-01"/> <!-- <label><b>GPA:</b></label> <input type ="text" name="gpavalue"/> --> </div> <br><br> <div style="margin:10px"> <label><b>Country:</b></label> <input type ="text" name="countryname"/> <label><b>State:</b></label> <input type ="text" name="statename"/> </div> <br><br> <div style="margin:10px"> <label><b>District:</b></label> <input type ="text" name="districtname"/> <b>Phone:</b> <input type="tel" name="phone"/> </div> <br><br> <!-- <div style="margin:10px"> <label><b>Gender: </b></label> <input type="text" name="gender" list="genderlist" /> <datalist id = "genderlist" > <option value = "Male" > <option value="Female"> </datalist> --> <input type="submit" value ="click to save" style="text-align:center;background-color:#ff8000;width:200px"/> </div> </form> {{ form.errors }} </body> </html> {% endblock %} When I add {{ form.as_p }} near the submit button tag in the HTML file, I am getting extra boxes as show in the below screenshot: The boxes shown below the "click to save" are the ones appearing after using {{form.as_p}}. Obviously, its picking up from the django model that I have created, and when I enter the data here, its saving the data in the DB. However, I wish to bind my model to the boxes appearing above the "click to save". I have tried adding {{form.photo}}, {{form.country}} and so on below each </div>, but its not working. The entire UI is getting distorted. 2) The "DOB" field is not saving data in DB. models.py--------------class UserProfile(models.Model): Photo = models.FileField(upload_to='documets/%Y/%m/%d/', null=True) uploaded_at = models.DateTimeField(auto_now_add=True, null=True) dob = models.DateField(max_length=20, null=True) country = models.CharField(max_length=100, null=True) State = models.CharField(max_length=100, null=True) District = models.CharField(max_length=100, null=True) phone = models.CharField(max_length=10, null=True)forms.py------------from django import forms from .models import UserProfile class ProfileForm(forms.ModelForm): Photo = forms.FileField( max_length=100) dob = forms.DateField() country = forms.CharField(max_length=100) State = forms.CharField(max_length=100) District = forms.CharField(max_length=100) phone = forms.CharField(max_length=10) class Meta: model = UserProfile fields = ('Photo', 'dob', 'country', 'State', 'District', 'phone')screenshot from the table query from DB------------------------------------------------------ As one could see that every field from the model is sending data to the DB but DOB. Please help.. Regards, Amitesh -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/225658712.187807.1587733349680%40mail.yahoo.com.