glamorous-teacher-52191
01/26/2022, 3:04 PMinline validation
https://htmx.org/examples/inline-validation/ - and was wondering if anyone had success with file
type inputs?
My case is that I'd like to do some validation as soon as a file is added to a file field, before submitting the form, but it seems the POST request acts a bit differently, and I'm not sure how to handle on the Django side.
If I were to submit the form normally, the contents of request.FILES
would contain a InMemoryUploadedFile
that could be processed by Django, but with a POST on the field change itself, the request.FILES
dict is empty, and instead there's a [object File]
in request.POST
, which seems to just be a string.
Any help or pointers would be appreciated πplain-kangaroo-26043
01/26/2022, 7:00 PMglamorous-teacher-52191
01/26/2022, 7:05 PMbrave-magazine-28098
01/27/2022, 3:01 AMbland-coat-6833
01/27/2022, 9:21 AMplain-kangaroo-26043
01/27/2022, 1:49 PMplain-kangaroo-26043
01/27/2022, 1:51 PMplain-kangaroo-26043
01/27/2022, 2:28 PMhundreds-camera-24900
01/27/2022, 3:00 PMbrave-magazine-28098
01/27/2022, 7:50 PMplain-kangaroo-26043
01/27/2022, 8:33 PMbland-coat-6833
01/27/2022, 9:18 PMcareful-room-54859
01/28/2022, 1:56 AMeager-tiger-27508
01/28/2022, 3:30 AMbrave-magazine-28098
01/28/2022, 7:35 AMmysterious-toddler-20573
01/30/2022, 8:59 PMmost-electrician-29577
01/31/2022, 11:45 PMbland-coat-6833
01/31/2022, 11:54 PMextends
in a test for request.htmx
in your template (assuming you're using the django-htmx
library).bland-coat-6833
01/31/2022, 11:55 PMmost-electrician-29577
02/01/2022, 12:03 AMbland-coat-6833
02/01/2022, 12:26 AM{% if request.htmx %}{% extends 'β¦' %}{% endif %}
most-electrician-29577
02/01/2022, 12:40 AMancient-rose-1570
02/01/2022, 9:24 AM<div hx-get="{% url "deals:deal-create" listing.slug %}" hx-trigger="load" id="htmx-ref">
{% include "includes/loading.html" %}
</div>
if the view at that url returns 403 I see the loading part.
Is there a better way to handle loading state?bland-coat-6833
02/01/2022, 10:03 AMloading.html
while you do a GET
to deals:deal-create
. If you get a 403 then you want to replace loading... with an error or some such?ancient-rose-1570
02/01/2022, 10:03 AMbland-coat-6833
02/01/2022, 10:05 AMbland-coat-6833
02/01/2022, 10:05 AMbland-coat-6833
02/01/2022, 10:06 AMdiv
with an error message