ModelFormMixing's handling of "success_url" is inconsistent with old generic view behaviour
|Reported by:||Gabriel Grant||Owned by:||Gabriel Grant|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Handling of "success_url" in ModelFormMixing seems to be inconsistent with how "get_absolute_url" is handled in views.generic.create_update.redirect()
In old generic views, the url could be a format string into which the object's fields would be interpolated. But that doesn't happed in ModelFormMixin: form_valid() just redirects to the result of get_success_url() (which doesn't do the interpolation)
This inconsistency should be dealt with by either:
- documenting the discrepency in here (presumably with the suggestion that the reader override the "get_success_url()" method to implement the interpolation)
- patching ModelFormMixin.get_success_url() to be consistent with old generic view handling and document the behaviour here
I prefer the latter, but the behaviour change could be a design decision (which I'm certainly not qualified to override :). Let me know, and I can prepare a patch.
Also, as an aside, it seems that redirecting back to the POSTed form would be a better last-resort, rather than throwing an ImproperlyConfigured error.
Change History (5)
comment:1 Changed 6 years ago by
|Patch needs improvement:||unset|