Skip to content

fix(admin): keep base_catalog pre-filled after save and add another#63

Open
ccantillo wants to merge 3 commits into
mainfrom
crls/fix/sticky-base-catalog-on-add-another
Open

fix(admin): keep base_catalog pre-filled after save and add another#63
ccantillo wants to merge 3 commits into
mainfrom
crls/fix/sticky-base-catalog-on-add-another

Conversation

@ccantillo

Copy link
Copy Markdown
Contributor

sticky base_catalog on "Save and add another"

Keep the Base catalog field pre-filled when an admin clicks
"Save and add another" in the BaseCatalogCourse admin page.

Context

Related issue: sticky base_catalog after save-and-add-another in
/admin/partner_catalog/basecatalog/
.

When adding multiple courses to the same BaseCatalog one by one,
clicking "Save and add another" redirected to a blank add form,
forcing the user to re-select the catalog every time. The only
workarounds were going back to the previous page or copy-pasting
the catalog ID manually.

Root cause

Django admin's default response_add redirect to /add/ does not
carry any query parameters, so the base_catalog raw-id field is
always empty on the next form load.

Change

Two small overrides added to BaseCatalogCourseAdmin in
partner_catalog/admin.py:

  • response_add — when _addanother is in the POST data,
    redirects to /add/?base_catalog=<id> instead of the plain /add/,
    preserving the catalog that was just used.
  • get_changeform_initial_data — reads the base_catalog GET
    parameter and injects it into the form's initial data so the
    raw-id widget renders with the value already set.

@ccantillo ccantillo requested a review from Alec4r July 2, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant