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

Issue with django-rest-auth and dj-rest-auth libraries #14

Open
pasevin opened this issue Aug 22, 2020 · 6 comments
Open

Issue with django-rest-auth and dj-rest-auth libraries #14

pasevin opened this issue Aug 22, 2020 · 6 comments

Comments

@pasevin
Copy link
Contributor

pasevin commented Aug 22, 2020

Not sure why, but can't use this library together with https://github.com/Tivix/django-rest-auth or later fork https://github.com/jazzband/dj-rest-auth. Keep getting errors of this type for all responses: TypeError: 'Password has been reset with the new password.' is not JSON serializable

@Amertz08
Copy link
Owner

I'll have to look through this more in depth. Thank you for bringing it to my attention. My guess here is that at some point that string literally ("Password has been reset with a new password.") is being passed into the renderer. Why that is happening is what we'd need to dig into.

@double-di
Copy link

Yes, having same problem, but with /logout method. 'Успешно вышли.' is not JSON serializable. I think it has something to do with utf8 serialization

@pasevin
Copy link
Contributor Author

pasevin commented Sep 16, 2020

@double-di for now my solution was just to subclass the view which is failing and set renderer_classes = [JSONRenderer]

@Amertz08
Copy link
Owner

What is the data parameter in the render coming through as? The error seems to indicate it is a string. However that should work with ujson.dumps

>>> import ujson
>>> ujson.dumps("a")
'"a"'
>>> ujson.dumps(b"a")
'"a"'
>>> import json
>>> ujson.dumps("a".encode())
'"a"'
>>> json.dumps("a")
'"a"'
>>> json.dumps(b"a")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable
>>> json.dumps("a".encode())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/Users/adammertz/.pyenv/versions/3.6.6/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'bytes' is not JSON serializable

@Amertz08
Copy link
Owner

Amertz08 commented May 2, 2021

@pasevin are you still having this issue?

@pasevin
Copy link
Contributor Author

pasevin commented Sep 21, 2021

@pasevin are you still having this issue?

Yes, it's still happening, unfortunately.

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

3 participants