django-polymorphic icon indicating copy to clipboard operation
django-polymorphic copied to clipboard

Admin: add view popup breaks if initial submit has validation error

Open pannkotsky opened this issue 1 year ago • 0 comments

Scenario:

  • in Django admin click green + next to the foreign key field that opens PolymorphicParentModelAdmin add 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

pannkotsky avatar Jul 23 '24 09:07 pannkotsky