Model.py
class Employee(models.Model):
empID = models.CharField(max_length=5)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
gender = models.CharField(max_length=2)
dob = models.DateField()
pan_num = models.CharField(max_length=15)
adhar_num = models.CharField(max_length=15)
mobile = models.CharField(max_length=15)
emailID = models.EmailField()
office_mail = models.CharField(max_length=150)
permanent_address = models.TextField()
present_address = models.TextField()
blood_group = models.CharField(max_length=5)
doj = models.DateField()
emp_level = models.CharField(max_length=13)
post_name = models.CharField(max_length=30)
basic_pay = models.DecimalField(max_digits=30, decimal_places=4)
house_allowance = models.DecimalField(max_digits=20, decimal_places=4)
Edit.html
{% csrf_token %}Update |
views.py
def update(request, id):
employee = Employee.objects.get(id=id)
form = EmployeeForm(request.POST, instance=employee)
form.save()
return redirect(’/show’)
I am a newbie in Django I am trying to update the form but I am unable to do it. Its always showing
ValueError at /update/10
The Employee could not be changed because the data didn’t validate.
please help