app-generator / sample-django-datatables

Django - Datatables Sample | AppSeed
https://django-datatables-sample.appseed.us
Other
81 stars 32 forks source link

I have problems with editing in row edit of the table template #10

Open djole988 opened 1 year ago

djole988 commented 1 year ago

When i reconfigure, list.html, edit_row.html change pattern urls, views, models, etc. I got in situation, that everithing is working, but when i double click on the row it opens prefiled fields, cancel button is working, but when i hit save button in edit_row.html i get error. I tried to find the error but i cannot find it. Can anyone help me with this?

the error:

Request body: b'task_id=3046.002&task_name=Djorjde&creation_date=2023-05-09&realization_date=2023-06-01&status=Ongoing&task_id=&task_name=&creation_date=&realization_date=&status=' Form data: <QueryDict: {'task_id': ['3046.002', ''], 'task_name': ['Djorjde', ''], 'creation_date': ['2023-05-09', ''], 'realization_date': ['2023-06-01', ''], 'status': ['Ongoing', '']}> Form errors:

this is from console after i put some debug console logs in views.py

....

def update_instance(self, request, pk, is_urlencode=False): task = self.get_object(pk) form_data = QueryDict(request.body) if is_urlencode else request.POST

    print("Request body:", request.body)  
    print("Form data:", form_data)  

    form = TaskForm(form_data, instance=task)
    # print(form_data)

    if form.is_valid():
        form.save()
        if not is_urlencode:
            messages.success(request, 'Transaction saved successfully')

        return True, 'Transaction saved successfully'
    else:
        print("Form errors:", form.errors) 

    if not is_urlencode:
        messages.warning(request, 'Error Occurred. Please try again.')
    return False, 'Error Occurred. Please try again.'

Everithing else is functioning, like edit button in row of volt in drop down and saving changes etc.