Skip to content
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

Serializers rendered as HTML may not indicate current value in select widgets. #2416

Closed
xordoquy opened this issue Jan 14, 2015 · 9 comments
Closed
Labels
Milestone

Comments

@xordoquy
Copy link
Collaborator

The select combo boxes don't take existing values into account for select widgets. This means that users don't see the selected value in the update view.

The test at https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/templates/rest_framework/horizontal/select.html#L11 is failing because:

  • key is a string
  • field.value is an integer
@tomchristie tomchristie changed the title HTML renderer's select ignores current values Serializers rendered as HTML may not indicate current value in select widgets. Jan 14, 2015
@tomchristie
Copy link
Member

Makes sense - maybe worth including a screenshot to make this completely clear to anyone else reading through this.

@tomchristie tomchristie added this to the 3.0.4 Release milestone Jan 14, 2015
@tomchristie
Copy link
Member

Not immediately obvious what the right way to fix this is. Something like either:

  • Coerce both the tested values to strings.
  • Don't coerce the choice to a string in the first place.

@xordoquy
Copy link
Collaborator Author

As one can see hereunder, we do have a value for the user field (user id 4) but it appears as if this field is empty.

Uploading Capture d’écran 2015-01-14 à 18.43.27.png . . .

Edit: I'll try to upload once I'm back home, I suspect my 3G provider cuts the images.

@xordoquy
Copy link
Collaborator Author

I'm not sure which one is the best answer though I tend to prefer to keep the native types - i.e. don't coerce the choice to a string.
I'm not sure either what the test would look like.

@xordoquy
Copy link
Collaborator Author

Way better without accents.

screenshot

@tomchristie
Copy link
Member

Changing the milestone on this - likely that we'll work on it as part of the focusing on HTML inputs with 3.2.0. Can reconsider if anyone wants to tackle it prior to that.

@aericson
Copy link
Contributor

Seems like an easy picking for me to start up contributing. Considering that in ChoiceField the key is not coerced to string I guess it would be best to keep same approach. Any other thoughts on this?

@tomchristie
Copy link
Member

@aericson Nothing from me I'm afraid - not given this one much thought lately but it'd be great to see someone have a dig into trying to resolve it.

aericson added a commit to aericson/django-rest-framework that referenced this issue Feb 15, 2015
@tomchristie tomchristie modified the milestones: 3.2.0 Release, 3.3.0 Jun 3, 2015
aericson added a commit to aericson/django-rest-framework that referenced this issue Jul 14, 2015
Fixes: encode#2416

choices() also did not work if queryset was a manager.
It would raise a "'*Manager' object is not iterable" that would
later get silenced by Django template system.
aericson added a commit to aericson/django-rest-framework that referenced this issue Jul 14, 2015
Fixes: encode#2416

choices() also did not work if queryset was a manager.
It would raise a "'*Manager' object is not iterable" that would
later get silenced by Django template system.
@tomchristie tomchristie modified the milestones: 3.1.4 Release, 3.3.0 Release Jul 14, 2015
@tomchristie
Copy link
Member

Resolved via 6b08e97

@tomchristie tomchristie removed this from the 3.1.4 Release milestone Jul 30, 2015
@tomchristie tomchristie modified the milestones: 3.2.0 Release, 3.1.4 Release Jul 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants