I have Job Model
that I can see list of them, create new one and see details of one of them. But when I want to edit objects of this model, I got this error:
match = datetime_re.match(value) TypeError: expected string or bytes-like object
And in Traceback
this line be come bold:
job_resume.save()
This is my files:
#Views.py
resume = get_object_or_404(JobRecord, id=id)
if request.method == "POST":
form = AddAdminJobForm(request.POST, request.FILES,instance=resume)
if form.is_valid():
job_resume = form.save(commit=False)
job_resume.upload_url = form.cleaned_data['upload_url']
job_resume.time_start = date_picker(date=request.POST['time-start-input'])
job_resume.time_end = date_picker(date=request.POST['time-end-input'])
job_resume.save()
return redirect('administrator:view_admin_job_resume')
else:
form = AddAdminJobForm(instance=resume)
template = 'administrator/resumes/add_edit_resume.html'
context = {'form': form}
return render(request, template, context)
#forms.py
class AddAdminJobForm(ModelForm):
class Meta:
model = JobRecord
fields = '__all__'
#date_picker function:
def date_picker(date):
if date:
gregorian_date = jdatetime.date.togregorian(jdatetime.datetime.strptime(date, "%Y/%m/%d"))
else:
gregorian_date = jdatetime.date.togregorian(jdatetime.datetime.now().date())
return gregorian_date
What is wrong with this codes?