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

Fixed #25132 -- Added the get_value() method to the QuerySet class #5004

Closed
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@thedrow

thedrow commented Jul 16, 2015

The method gets a single value from a single object and returns it.
I also covered get() with tests that match get_value()'s tests.

thedrow added some commits Jul 16, 2015

Added the get_value() method to the QuerySet class which gets a singl…
…e value from a single object and returns it.

Also covered get() with tests that match get_value()'s tests.
@charettes

This comment has been minimized.

Show comment
Hide comment
@charettes

charettes Jul 16, 2015

Member

Isn't this already achievable with values_list('field', flat=True).get(pk=1)?

Member

charettes commented Jul 16, 2015

Isn't this already achievable with values_list('field', flat=True).get(pk=1)?

@thedrow

This comment has been minimized.

Show comment
Hide comment
@thedrow

thedrow Jul 16, 2015

I'm not sure but I think that would return a list anyway. I'd like to fetch a single field from the database.

thedrow commented Jul 16, 2015

I'm not sure but I think that would return a list anyway. I'd like to fetch a single field from the database.

@charettes

This comment has been minimized.

Show comment
Hide comment
@charettes

charettes Jul 16, 2015

Member

I just tried it and it returns a single value from the database. I don't think we need to introduce another method for this use case.

Member

charettes commented Jul 16, 2015

I just tried it and it returns a single value from the database. I don't think we need to introduce another method for this use case.

@thedrow

This comment has been minimized.

Show comment
Hide comment
@thedrow

thedrow Jul 16, 2015

@charettes I just checked myself and it returned a tuple with the field's value.
The method just provides some syntax sugar for those who need it.

thedrow commented Jul 16, 2015

@charettes I just checked myself and it returned a tuple with the field's value.
The method just provides some syntax sugar for those who need it.

@charettes

This comment has been minimized.

Show comment
Hide comment
@charettes

charettes Jul 16, 2015

Member

It cannot return a tuple if you use the flat=True kwarg. You even use this method in your get_value implementation.

Member

charettes commented Jul 16, 2015

It cannot return a tuple if you use the flat=True kwarg. You even use this method in your get_value implementation.

@thedrow

This comment has been minimized.

Show comment
Hide comment
@thedrow

thedrow Jul 16, 2015

That's a surprise. I would suggest a documentation change instead.

thedrow commented Jul 16, 2015

That's a surprise. I would suggest a documentation change instead.

@timgraham timgraham changed the title from Added the get_value() method to the QuerySet class to Fixed #25132 -- Added the get_value() method to the QuerySet class Jul 16, 2015

@timgraham timgraham closed this Jul 16, 2015

@thedrow thedrow deleted the thedrow:feature/queryset-value-method branch Jul 16, 2015

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