adamchainz / django-htmx

Extensions for using Django with htmx.
https://django-htmx.readthedocs.io/
MIT License
1.66k stars 140 forks source link

hx-put, hx-delete #408

Closed onno-timmerman closed 11 months ago

onno-timmerman commented 11 months ago

Description

Recently I want to do more with class based views so I can do much more in one url. But django lacks something to do this correctly.

In a view we can have, get, post, put, delete If you use your form to you will have request.POST or request.GET. But no request.DELETE and request.PUT like in DRF. If we would have that then can lift hx-delete and hx-put to use in your class based view I think that django-htmx can extend the request with delete and put? Maybe this should be feature request in Django? or am I missing something?

https://htmx.org/attributes/hx-patch/ https://htmx.org/attributes/hx-put/ https://htmx.org/attributes/hx-delete/

https://code.djangoproject.com/ticket/12635 https://code.djangoproject.com/ticket/34775 https://code.djangoproject.com/ticket/32428

adamchainz commented 11 months ago

If you use your form to you will have request.POST or request.GET.

These names are unclear. I proposed renaming them in 2020: https://groups.google.com/g/django-developers/c/Kx8BfU-z4_E/m/gJBuGeZTBwAJ . I believe we will gradually get there in Django, along with a request.data proposal that copies from DRF. The last PR working on this: https://github.com/django/django/pull/17546 .

I don't think we should do anything in django-htmx, and keep this to Django. For the time being, you can use Django’s MultiPartParser to parse incoming form data on non-POST submissions.

But no request.DELETE and request.PUT like in DRF.

I don’t believe these exist: https://www.django-rest-framework.org/api-guide/requests/ .