This is my edit.html code and during retrieving the values from database it shows only the text fields like value={{ i.full_name}} but when I am writing value={{ i.cv}}, value={{ i.status}}, value={{ i.gender}} it does not shows the value which needs to bed edited I have two choice fields and one file field.
this is my edit.html
<section class="site-section">
<div class="container">
<div class="row">
<div class="col-lg-12 mb-5">
<h2 class="mb-4 text-center">Update Candidate Details</h2>
<form method="POST" action="/update/ {{i.id}}/" enctype="multipart/form-data" class="p-4 border rounded" onsubmit="myFunction()" >
{% csrf_token %}
{% comment %} <input type="hidden" name="csrfmiddlewaretoken" value="UabxqpD8HGPOu1ZSFnIHAPbMtRgWBAnVHEs8bLDx0HnxN6uhG3LyYvZShvcx1ekn"> {% endcomment %}
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="full_name">Full Name :</label>
<input type="text" class="form-control" value ={{ i.full_name}} name="full_name" id="id_full_name" placeholder="Enter First Name">
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="recruiter_name">Recruiter Name :</label>
<input type="text" class="form-control" value ={{ i.recruiter_name }} name="recruiter_name" id="id_recruiter_name" placeholder="Enter Recruiter Name">
</div>
</div>
{% comment %} <div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="id_last_name">Last Name :</label>
<input type="text" class="form-control" name="last_name" id="id_last_name" placeholder="Enter Last Name">
</div>
</div> {% endcomment %}
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="email">Email :</label>
<input type="email" class="form-control" value ={{i.email }} name="email" id="id_email" placeholder="Enter Email">
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="noticeperiod">Notice Period (in Days) :</label>
<input type="text" class="form-control" value ={{i.noticeperiod }} name="noticeperiod" id="notice_period" placeholder="Notice Period">
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="preferredlocation">Current Location :</label>
<input type="text" class="form-control" value ={{i.preferredlocation}} name="preferredlocation" id="preferred_location" placeholder="Enter Current Location">
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="expectedlocation">Expected Location :</label>
<input type="text" class="form-control" value ={{i.expectedlocation}} name="expectedlocation" id="expected_location" placeholder="Enter Multiple Locations seperated by comma">
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="currentctc">Current CTC (Per Annum) :</label>
<input type="text" class="form-control" value ={{i.currentctc }} name="currentctc" id="current_ctc" placeholder="Current CTC">
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="expectedctc">Expected CTC (Per Annum) : </label>
<input type="text" class="form-control" value ={{i.expectedctc }} name="expectedctc" id="expected_ctc" placeholder="Expected CTC">
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" for="status">Status : </label> </br>
<select name="status" id="status" class="form-control" value ={{i.status }}>
<option value="CV Received">CV Received</option>
<option value="Submitted to Client">Submitted to Client</option>
<option value="Rejected">Rejected</option>
<option value="Offered">Offered</option>
<option value="Joined">Joined</option>
<option value="Closed">Closed</option>
<option value="Payment Received">Payment Received</option>
</select>
{% comment %} <input type="text" class="form-control" name="status" id="status1" placeholder="Enter Application Status"> {% endcomment %}
</div>
</div>
<div class="row form-group">
<div class="col-md-12 mb-3 mb-md-0">
<label class="text-black" >Upload CV</label></br>
<input type="file" name="cv" id="cv1" value ={{ i.cv}} >
</div>
</div>
<div class="row form-group mb-4">
<div class="col-md-12 mb-3 mb-md-0">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" id="male" value={{i.gender}}>
<label class="form-check-label" for="male">Male</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="gender" id="female" value={{i.gender}}>
<label class="form-check-label" for="female">Female</label>
</div>
</div>
</div>
<div class="row form-group">
<div class="col-md-12">
<input type="submit" value="Update" id ="submit" class="btn px-4 btn-primary text-white">
{% comment %} <a href="{% url 'jobapp:jobconfirm' %}" class="btn btn-warning btn-block btn-lg">Sign Up</a> {% endcomment %}
</div>
</div>
this is my views.py
#delete
def delete(request, id):
i = ApplyForm.objects.get(id = id)
i.delete()
return redirect('account:dboard')
#edit
def edit(request, id):
i = ApplyForm.objects.get(id = id)
context = {
'i' : i
}
return render(request, 'account/edit.html', context)
#update
def update(request, id):
i = ApplyForm.objects.get(id = id)
i.full_name = request.POST['full_name']
i.email = request.POST['email']
i.noticeperiod = request.POST['noticeperiod']
i.preferredlocation = request.POST['preferredlocation']
i.expectedlocation = request.POST['expectedlocation']
i.currentctc = request.POST['currentctc']
i.expectedctc= request.POST['expectedctc']
i.recruiter_name = request.POST['recruiter_name']
i.status = request.POST['status']
i.gender = request.POST['gender']
i.cv = request.FILES['cv']
i.save()
return redirect('account:dboard')
this is my models.py
class ApplyForm(models.Model):
full_name = models.CharField(max_length=300)
email = models.EmailField(max_length=300)
noticeperiod = models.CharField(max_length = 300)
preferredlocation = models.CharField(max_length=300)
expectedlocation = models.CharField(max_length=300)
currentctc = models.CharField(max_length=300)
expectedctc = models.CharField(max_length=300)
recruiter_name = models.CharField(max_length = 300, null=True)
status = models.CharField(max_length = 300, null=True, choices= CATEGORY_CHOICES )
gender = models.CharField(max_length=10, choices=GENDER_CHOICES)
cv = models.FileField(upload_to='')
I want a solutions here
1.I cant retrieve the values of Upload cv, Gender , Status by doing value={{ i.cv}}, value={{ i.status}}, value={{ i.gender}} while the text fields are working fine I am getting the value that means I can display the value of full name with this value={{ i.full_name}} in my form but not the choice and file fields Where I am going wrong I dont know.