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

CallableBool(True) is not JSON serializable #77

Closed
wx2228 opened this issue Jul 5, 2017 · 2 comments
Closed

CallableBool(True) is not JSON serializable #77

wx2228 opened this issue Jul 5, 2017 · 2 comments

Comments

@wx2228
Copy link

wx2228 commented Jul 5, 2017

how do I pass in a boolean? this is the code:

def get_context_data(self, **kwargs):
        ctx = super(QuestionListView, self).get_context_data(**kwargs)
        user = self.request.user
        is_authenticated = user.is_authenticated
        display_name = user.display_name if is_authenticated else None
        reputation_point = user.reputation if is_authenticated else None
        ctx['react_nav'] = render_component(
            'js/nav.jsx',
            props={
                'authenticated': is_authenticated,
                'displayName': display_name,
                'reputation': reputation_point
            })
        return ctx

I can't pass in `is_authenticated` to `props`
@markfinger
Copy link
Owner

Something like is_authenticated = bool(user.is_authenticated) should do the trick.

It looks like is_authenticated is a lazily evaluated value, or something odd which is trying to enable both a property getter and a method call on the same property. In effect, the JSON serialiser doesn't know to derive a primitive value from CallableBool instances.

@wx2228
Copy link
Author

wx2228 commented Jul 6, 2017

thanks!!!

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

No branches or pull requests

2 participants