Skip to content

Commit 72a130c

Browse files
committed
Preserve active filters in Edit/Delete return URL
Change return_url from request.path to request.get_full_path() so that query params (search, type filter, sort, page) are included. After saving an edit or confirming a deletion the user is returned to the tab with the same filters active.
1 parent 0592707 commit 72a130c

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5151

5252
- **Edit/Delete return URL** — after saving an edit or confirming a deletion, NetBox now
5353
redirects back to the Custom Objects tab instead of to the Custom Object list page.
54+
- **Filter state preserved on return** — active filters (`?q=`, `?type=`, `?sort=`, `?dir=`,
55+
`?per_page=`, `?page=`) are retained in the return URL so the user lands back on the same
56+
filtered/sorted view after editing or deleting a custom object.

CLAUDE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ Action buttons and column links use the `perms` templatetag from `utilities.temp
115115
left-hand value and the object instance as the argument.
116116
- Edit and Delete are rendered as **inline `<a>` buttons** (not inclusion tags) so that
117117
`?return_url={{ return_url|urlencode }}` can be appended. `return_url` is set in the
118-
view context as `request.path` (the tab URL, e.g. `/dcim/devices/42/custom-objects/`).
118+
view context as `request.get_full_path()` (path + query string, e.g.
119+
`/dcim/devices/42/custom-objects/?q=foo&sort=type&dir=asc`), so active filters are
120+
preserved when the user returns from Edit or Delete.
119121
- The `custom_object_edit_button` / `custom_object_delete_button` inclusion tags from
120122
`netbox_custom_objects` do **not** accept a `return_url` argument — do not use them.
121123
- Do **not** add bulk-edit or bulk-delete buttons to this tab — the tab shows objects

netbox_custom_objects_tab/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def get(self, request, pk):
259259
'sort_dir': sort_dir,
260260
'sort_headers': sort_headers,
261261
'htmx_table': SimpleNamespace(htmx_url=request.path, embedded=False),
262-
'return_url': request.path,
262+
'return_url': request.get_full_path(),
263263
}
264264

265265
if htmx_partial(request):

0 commit comments

Comments
 (0)