django-polymorphic
django-polymorphic copied to clipboard
Admin: add view popup breaks if initial submit has validation error
Scenario:
- in Django admin click green + next to the foreign key field that opens
PolymorphicParentModelAdminadd view - Submit form with validation error
- Fix the error and submit again
Expected:
- object is added, popup is closed, object is populated to the foreign key field widget on the original form
Actual:
- popup is not closed, field widget is not populated
This happens because after initial submit with validation error the query params indicating popup are removed, and only ct_id param is preserved. It comes from the following lines of code: https://github.com/jazzband/django-polymorphic/blob/master/polymorphic/admin/parentadmin.py#L202-L208