Object of type 'QuerySet' is not JSON serializable. Queryset not supporting in function call.
See original GitHub issueBackground task does not work if we pass a queryset inside a method and gives back an error.
user_detail = User.objects.get(id=1)
@background(schedule=datetime.now())
def notify_user(user_detail):
pass
Object of type ‘QuerySet’ is not JSON serializable.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
<Django object > is not JSON serializable - Stack Overflow
simplejson and json don't work with django objects well. Django's built-in serializers can only serialize querysets filled with django objects:
Read more >Object of type QuerySet is not JSON serializable - Django Forum
Hello, I'm trying to display some info from models through views as a list of dictionaries in JSON format but I get the...
Read more >TypeError: Object of type QuerySet is not JSON serializable
In Django, we cannot directly convert queryset into JSON because the Object of type QuerySet is not JSON serializable.
Read more >Django object is not JSON serializable | Edureka Community
I have the following code for serializing the queryset; def render_to_response(self, context, ** ... both django objects and dicts.
Read more >Django: "TypeError: [] is not JSON serializable" Why?
Querysets are not serializable out-of-the-box. If you try list(self.items) instead of just self.items , that should work as long as the items themselves...
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
This is how BGT is designed to work. Just pass the the ID and do the query inside
notify_user
.So how it is more efficient that cron job. Is it not that cron is much better for repeating tasks compared to BGT. Can you give a better use case of BGT for repetitive tasks compared to cron.