Skip to content

Commit f0fe5cc

Browse files
mattstrattonclaude
andcommitted
Fix Inertia form save: return 303 redirect after POST
Inertia.js expects a 303 status code redirect after successful form submissions. Also handle both JSON and form-encoded POST bodies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 543b8c3 commit f0fe5cc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

apps/events/manage_views.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ def event_edit(request, event_slug):
6767
return HttpResponseForbidden("You don't have permission to manage this event.")
6868

6969
if request.method == "POST":
70-
data = json.loads(request.body)
70+
content_type = request.content_type or ""
71+
if "application/json" in content_type:
72+
data = json.loads(request.body)
73+
else:
74+
data = request.POST.dict()
75+
7176
for field in ["description", "location_name", "location_address", "organizer_email",
7277
"cfp_link", "registration_link", "social_twitter", "social_linkedin",
7378
"social_mastodon", "social_bluesky"]:
@@ -77,7 +82,12 @@ def event_edit(request, event_slug):
7782
if field in data:
7883
setattr(event, field, bool(data[field]))
7984
event.save()
80-
return redirect(f"/manage/events/{event.slug}/")
85+
86+
# Inertia expects a 303 redirect after a successful POST
87+
from django.http import HttpResponseRedirect
88+
response = HttpResponseRedirect(f"/manage/events/{event.slug}/")
89+
response.status_code = 303
90+
return response
8191

8292
# GET — render the edit page
8393
team_members = list(event.team_members.values(

0 commit comments

Comments
 (0)