[Answer]-Not able to compare and update a form field and model field django

1👍

# for create and update view
def form_valid(self, form):
    admin_time = form.cleaned_data.get('admin_time')
    task_object = form.save(self.request.user, commit=False)
    if admin_time:
        task_object.execution_time = admin_time
    task_object.save(self.request.user)


# update
def clean_execution_time(self):
    execution_time = self.cleaned_data.get('execution_time')
    admin_time = self.cleaned_data.get('admin_time')
    if admin_time:
        self.cleaned_data['execution_time'] = execution_time = admin_time

    return execution_time

Leave a comment