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

Subfieldbase removal causes unexpected behavioural in QS.values_list() #40

Closed
jenlu opened this issue Jan 23, 2016 · 2 comments
Closed

Comments

@jenlu
Copy link

jenlu commented Jan 23, 2016

When correcting the deprecation of SubFieldBase (just removed it and added from_db_value, works sort of) all is OK except a new unexpected behavior from QuerySet and values_list.

Prior to this doing values_list(...) on the query set returned something like:
[u'L', u'J', u'L' ] but now it returns [([u'L'],), ([u'J'],), ([u'L'],)]

this is obviously as the to_python returns a list (which is correct), but still, not sure why this ever worked in first place and how this can be changed now (on what level to override this to keep old behavioural).

Secondly the .values_list on a multiselectfield is also open for possible interpretations, should it list values used or combination of values use ;-) but this is my problem...

Edit (by blag): Formatted with GFM

@blag
Copy link
Collaborator

blag commented Sep 22, 2016

What version of Django did you notice this with?

According to the Travis results, this only happens with Django 1.6 & 1.7.

I'll try to fix that and push it later today.

@blag
Copy link
Collaborator

blag commented Sep 23, 2016

This is a known Django bug #9619, and only happens for Django 1.6 and 1.7.

The workaround is to manually call .split(',') on the returned result.

Because there really isn't a clean way to handle this, and it's fixed in Django 1.8+, I'm not going to spend any development time fixing this. I have updated the documentation to shine light on this bug and will be publishing that soon though.

If somebody has time to create a QuerySet mixin that fixes this, I would adjusts the tests and accept that PR.

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

No branches or pull requests

2 participants