Fixes #20234: Correct add_button return_url for prerequisite models #1321

Closed
opened 2026-04-05 23:23:30 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @pheus on 9/5/2025

Fixes: #20234

Summary
The generic prerequisite include was passing request.path as the second positional argument to the add_button template tag. Because the tag expects (model, action, return_url), this caused request.path to be interpreted as action, breaking the "+ Add" link in banners such as "Before you can add a power feed you must first create a power panel."

Change
Pass the return_url by name so it’s bound correctly by the tag:

{% add_button prerequisite_model return_url=request.path %}

User impact
Clicking "+ Add" on any prerequisite banner now opens the correct add form and returns the user to the originating page upon completion.

*Originally created by @pheus on 9/5/2025* ### Fixes: #20234 **Summary** The generic prerequisite include was passing `request.path` as the second positional argument to the `add_button` template tag. Because the tag expects `(model, action, return_url)`, this caused `request.path` to be interpreted as `action`, breaking the "+ Add" link in banners such as "Before you can add a power feed you must first create a power panel." **Change** Pass the `return_url` by name so it’s bound correctly by the tag: ~~~django {% add_button prerequisite_model return_url=request.path %} ~~~ **User impact** Clicking "+ Add" on any prerequisite banner now opens the correct add form and returns the user to the originating page upon completion.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#1321