-
Notifications
You must be signed in to change notification settings - Fork 13
Re-rendering a form with validation errors results in blank fields #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi George, are you able to supply a test case for this issue? I have not had this issue and I'm wondering if there's something different in the way that you're using it. |
Hi @danni. Thanks for making such a useful addition to Django, and for the quick reply on the issue! I've put together a minimal Django app that demonstrates the issue: https://github.com/georgebrock/django-postgres-composite-types-issue-18 I also tried to add a test to this project's test suite, but I had trouble getting the suite to run. The issues I was hitting there seemed to be related to Django initialisation, so it's possible this is a Django 2.0 compatibility thing. |
Previously the submitted value for a composite field was lost if the form had a validation error. Fixes danni#18
Thanks for this! |
The fixes for this issue and #17, have been released in v0.4.1 on PyPI. |
When a form using a composite type widget is used with a generic form view (e.g.
django.views.generic.UpdateView
, or from the Django admin site), and the form has validation errors, the widgets that make up the composite type will be rendered without their values.The issue seems to be that the
CompositeTypeWidget.render
method usesgetattr(value, subname, None)
to retrieve the values for the individual fields. This fails because when we're rendering the form with validation errorsvalue
is adict
, and not an instance of a subclass ofCompositeType
(as it is when we're rendering the form without errors).The text was updated successfully, but these errors were encountered: