Skip to content

Conversation

@jamesbeith
Copy link
Contributor

Exception while resolving variable 'value' in template 'rest_framework/vertical/checkbox.html'.

I checked all the other templates and this appears to be the only case of a missing 'field'.

> Exception while resolving variable 'value' in template 'rest_framework/vertical/checkbox.html'.

I checked all the other templates and this appears to be the only case of a missing 'field'.
@xordoquy
Copy link
Contributor

@jamesbeith can you provide us some directions about how to reproduce the initial issue ?

@jamesbeith
Copy link
Contributor Author

Hope these step help. Essentially the Boolean field loses it value if the serializer is rendered again in a template. Do let me know if you want any more info or example.

Steps

  • Build upon this example, Rendering Forms, where you submit a form and errors are reported
  • Create a Serializer class with a BooleanField and a required CharField
  • Render the serializer in a HTML template using TemplateHTMLRenderer and the render_form template tag
  • In the browser check the checkbox but leave the text input blank
  • Submit the form

Expected Results

  • The serializer is invalid and the template rendered again
  • The error is reported that the CharField is required
  • The checkbox remains checked

Actual Results

  • The serializer is invalid and the template rendered again
  • The error is reported that the CharField is required
  • The checkbox is no longer checked and required checking again before submitting the form

@jamesbeith
Copy link
Contributor Author

Here's a test patch. Run against master the test will fail as "checked" is missing, which should not be the case the data value is "True". Hope that helps.

0001-Test.patch.zip

@lovelydinosaur
Copy link
Contributor

@jamesbeith - Could you supply the test patch as a pull request that adds the (failing) test?

@jamesbeith
Copy link
Contributor Author

@tomchristie #3872

@lovelydinosaur
Copy link
Contributor

Thanks for having raised this! Has been resolved since - merging in your test case and getting these closed off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants