91 days ago · Tech · hide · Fediverse post

Python A-Z is a blog series about Python. Each day, I share insights, ideas and examples for different parts of Python development that match with the letter of the day. Blaugust is an annual blogging festival in August where the goal is to write a blog post every day of the month. Second Django ORM post of the week! First, an important distinction before we start: this blog post is about Django’s Q objects and not about the task queue project Django Q (or its fork Django Q2). Maybe I’ll write about them the next time I need to come up with something for letter Q because that’s not a large pool of ideas. Basics Q objects are a way to write Django queries in a more composable way. These two are equivalent in outcome: from models import Card Card.objects.filter(name='Bulbasaur') # and from django.db.models import Q bulbasaur_query = Q(name='Bulbasaur') Card.objects.filter(bulbasaur_query) For a simple example like this, there’s not a lot to gain. They are more useful for complex…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town