hundreds-camera-24900
06/07/2022, 1:03 AMhundreds-camera-24900
06/07/2022, 1:04 AMhundreds-camera-24900
06/07/2022, 1:04 AMwhite-motorcycle-95262
06/07/2022, 8:25 PM<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'>
to set the token, but this results in an outdated token when users log in/out (I believe both of those actions result in Django cycling the CSRF Token).
How are other people refreshing the token for HTMX in these situations?white-motorcycle-95262
06/07/2022, 8:26 PMmelodic-advantage-28381
06/07/2022, 8:51 PMwhite-motorcycle-95262
06/07/2022, 9:05 PMhundreds-camera-24900
06/07/2022, 9:46 PMhundreds-camera-24900
06/07/2022, 9:47 PMwhite-motorcycle-95262
06/07/2022, 10:23 PMrefined-waiter-90422
06/07/2022, 10:49 PMrefined-waiter-90422
06/07/2022, 10:50 PMsilly-bear-76516
06/08/2022, 6:15 PMhx-post
as part of the request wherever the form is, it's something you already had to do if you were to use regular forms anyway (that's my reasoning)white-motorcycle-95262
06/08/2022, 6:33 PMgetCookie
silly-bear-76516
06/08/2022, 7:12 PMwhite-motorcycle-95262
06/08/2022, 7:16 PMadamant-insurance-51032
06/15/2022, 5:12 PMhx-delete
in combination with a Django DeleteView
from a TemplateView
(with a list of items). Everything is working fine, without the redirect after the delete. I get a 302 for the delete but then i get an 405 on my TemplateView
. I'm not sure why the redirect does a HTTP DELETE on my TemplateView
.important-van-94053
06/16/2022, 7:15 AMimportant-van-94053
06/16/2022, 7:22 AMadamant-insurance-51032
06/16/2022, 9:20 AMhx-delete="{% url 'deletebooking' booking.id %}"
hx-confirm="Are you sure you want to delete this item."
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-target="#booking-{{ booking.id }}"
hx-swap="outerHTML"`
And here is my "DeleteView"
python
class DeleteBookingView(LoginRequiredMixin, BaseDetailView):
http_method_names = ['delete']
model = Booking
def delete(self, request, *args, **kwargs):
self.object = self.get_object()
if self.object.user == self.request.user:
self.object.delete()
response = redirect(reverse_lazy('dashboard'))
response.status_code = 200
return response
else:
raise PermissionDenied()
important-van-94053
06/16/2022, 1:40 PMadamant-insurance-51032
06/16/2022, 1:51 PMancient-father-3063
06/21/2022, 7:58 AMancient-father-3063
06/21/2022, 8:32 AMancient-father-3063
06/21/2022, 8:32 AMancient-father-3063
06/21/2022, 8:33 AMancient-father-3063
06/21/2022, 8:33 AM{% render_field league_form.mtgFormat name="leagueformat" class="form-control" hx-trigger="change, load" hx-post="/account/enable" hx-target="#myDeck" %}
ancient-father-3063
06/21/2022, 8:33 AMancient-father-3063
06/21/2022, 8:34 AM<select class="form-control" hx-post="/leagues/formatdecks" hx-target="#myDeck" hx-trigger="change, load" id="id_mtgFormat" name="leagueformat" required="">
ancient-father-3063
06/21/2022, 8:34 AM