10000 Fix resolving var 'value', was missing 'field' by jamesbeith · Pull Request #3868 · encode/django-rest-framework · GitHub
[go: up one dir, main page]

Skip to content

Fix resolving var 'value', was missing 'field' #3868

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

Closed
wants to merge 1 commit into from
Closed

Fix resolving var 'value', was missing 'field' #3868

wants to merge 1 commit into from

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
Collaborator

@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

@tomchristie
Copy link
Member

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

@jamesbeith
Copy link
Contributor Author

@tomchristie #3872

@tomchristie
Copy link
Member

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
0