Database query in custom authentication cause SynchronousOnlyOperation Error
See original GitHub issueIn Custom Authentication section of documentation, there is database query in __call__
method:
def __call__(self, scope):
...
user = User.objects.get(id=int(scope["query_string"]))
...
It’s OK with Django 2, but in Django 3 it cause django.core.exceptions.SynchronousOnlyOperation
error.
please update docs, and explain how to use database query in Custom Authentications.
Thanks.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:25
- Comments:18 (8 by maintainers)
Top Results From Across the Web
python 3.x - Rarely get SynchronousOnlyOperation error in ...
What happens if you access your resource by going directly to the DB, without using the ORM? Django ORM is not allowing async...
Read more >[Solved]-SynchronousOnlyOperation Error in with django 3 ...
I have opened an issue for django channels about updating docs. @database_sync_to_async def get_user(token_key): try: return Token.objects.get(key=token_key).
Read more >Django Exceptions
SuspiciousMultipartForm; SuspiciousSession; TooManyFieldsSent. If a SuspiciousOperation exception reaches the ASGI/WSGI handler level it is logged at the Error ...
Read more >Custom Query – Django - djello
Support dictionaries in Field.choices for named groups. assigned, Tom Forbes, New feature, Database layer (models, ORM), dev. #31304 · PostgreSQL full-text ...
Read more >Compare Django release notes | CodeReview.doctor
Fixed a bug in Django 3.2 that caused a migration crash on MySQL 8.0.13+ when altering ... As a side-effect the private API...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jkupka You can use below code, Until docs be updated.
Hey, thanks for the work done thus far! Adapted @AmirMahmood solution for django rest framework’s token auth based on the old impl. See below: