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

Admin renderer displays True and False in place of integers 1 and 0 #3227

Closed
jsatt opened this issue Aug 6, 2015 · 4 comments
Closed

Admin renderer displays True and False in place of integers 1 and 0 #3227

jsatt opened this issue Aug 6, 2015 · 4 comments
Labels
Milestone

Comments

@jsatt
Copy link
Contributor

jsatt commented Aug 6, 2015

When viewing an endpoint using the Admin renderer, cases where the integer 1 or 0 should be displayed, such as object ids and foreign keys, instead display the corresponding True or False value..
drf-admin-truefalse

@jpadilla jpadilla added the Bug label Aug 6, 2015
@jpadilla
Copy link
Member

jpadilla commented Aug 6, 2015

That seems to be because of this in the format_value template filter.

>>> 1 in (True, False, None)
True

@jsatt
Copy link
Contributor Author

jsatt commented Aug 6, 2015

Looks like that should be changed to something like

if isinstance(value, bool) or value is None:

@jsatt
Copy link
Contributor Author

jsatt commented Aug 6, 2015

Or slightly more to the point:

from types import NoneType
...
if isinstance(value, (bool, NoneType)):

@tomchristie tomchristie modified the milestone: 3.2.1 Release Aug 7, 2015
@tomchristie
Copy link
Member

tomchristie commented Aug 7, 2015

Thanks folks.

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

No branches or pull requests

3 participants