▸case-01 We have an Order model with a ForeignKey to Customer in Django. When listing orders in an API view, we need to include customer details. A developer suggested iterating through orders and calling order.customer.name or adding prefetch_related('customer') in get_queryset. Provide the Django ORM queryset snippet that efficiently retrieves customer data in a single SQL JOIN query. | pass→pass | 6,298 | 4,796 | -24% | 1 | 1 | 0% | 712 | 1,011 | +42% | 0 | 0 | — |
▸case-02 In our Django application, an Article model has a ManyToManyField to Tag. We want to list articles with all their associated tags in an API list view without hitting the database for each article. Write the Django ORM queryset call to eliminate N+1 queries when accessing tags. | pass→pass | 3,797 | 4,442 | +17% | 1 | 1 | 0% | 686 | 1,109 | +62% | 0 | 0 | — |
▸case-03 We frequently filter our Django Transaction model by account_id and created_at together. A developer placed db_index=True on both fields separately. Show how to configure the model Meta class to create a composite index spanning both fields. | pass→fail | 10,341 | 6,049 | -42% | 1 | 1 | 0% | 1,715 | 1,196 | -30% | 0 | 0 | — |
▸case-04 We want to configure JSON Web Token authentication globally for a Django REST Framework project using the standard community simplejwt package. Show the REST_FRAMEWORK configuration dictionary in settings.py specifying the default authentication class. | pass→pass | 3,697 | 4,496 | +22% | 1 | 1 | 0% | 749 | 1,024 | +37% | 0 | 0 | — |
▸case-05 We need to expose API endpoints for acquiring and refreshing JSON Web Tokens in a Django project using simplejwt. Show the urlpatterns list in urls.py for obtaining token pairs and refreshing tokens. | pass→pass | 3,818 | 19,120 | +401% | 1 | 1 | 0% | 674 | 918 | +36% | 0 | 0 | — |
▸case-06 We have an Author model and a Book model where author is a ForeignKey on Book. We need a DRF serializer for Book that reads the complete Author details on serialization, but accepts an author ID on deserialization during create and update operations. Show the serializer implementation. | fail→pass | 21,232 | 9,151 | -57% | 1 | 1 | 0% | 2,120 | 1,980 | -7% | 0 | 0 | — |
▸case-07 We are writing a Django REST Framework serializer for a user registration payload containing an age field. We want field-level validation to reject any age under 18. Write the specific field validation method inside the serializer. | pass→pass | 3,302 | 3,746 | +13% | 1 | 1 | 0% | 553 | 849 | +54% | 0 | 0 | — |
▸case-08 We need to insert 5,000 Product records into PostgreSQL from a parsed CSV file in Django. A colleague proposed iterating over rows and calling Product.objects.create() for each row. Provide the optimal Django ORM code to insert all records in a single batch database operation. | pass→pass | 6,879 | 8,217 | +19% | 1 | 1 | 0% | 1,394 | 1,724 | +24% | 0 | 0 | — |
▸case-09 Our DRF endpoints currently return full unfiltered result sets. Show the REST_FRAMEWORK settings snippet in settings.py to configure global page-number pagination with a limit of 20 results per page. | pass→pass | 2,725 | 2,281 | -16% | 1 | 1 | 0% | 463 | 585 | +26% | 0 | 0 | — |
▸case-10 We have a Department model connected via reverse relationship to Employee. Write a Django ORM query that retrieves all departments along with an annotated field total_employees counting the associated employees for each department. | pass→pass | 4,404 | 4,695 | +7% | 1 | 1 | 0% | 755 | 1,072 | +42% | 0 | 0 | — |
▸case-11 We have a DRF ViewSet for managing company FinancialRecord instances. We must ensure only authenticated users can access any endpoint on this ViewSet. Show how to configure the permission classes on the ViewSet. | pass→pass | 4,283 | 3,936 | -8% | 1 | 1 | 0% | 834 | 937 | +12% | 0 | 0 | — |
▸case-12 A BlogPost model has a heavy body text field alongside title, slug, and published_at. On the post index listing page, body text is not rendered. Write the Django query to fetch posts while explicitly avoiding loading body text from the database. | pass→pass | 3,798 | 4,416 | +16% | 1 | 1 | 0% | 659 | 938 | +42% | 0 | 0 | — |
▸case-13 We use simplejwt in Django and need to add custom claims role and user_id into the generated JWT payload upon user login. Show how to subclass TokenObtainPairSerializer to append these custom claims. | pass→pass | 9,266 | 8,357 | -10% | 1 | 1 | 0% | 1,945 | 1,858 | -4% | 0 | 0 | — |
▸case-14 We want to enable query parameter filtering (status and category) on a DRF ListAPIView using django-filter. Show the view attributes needed to enable filtering for these fields. | pass→pass | 4,019 | 4,210 | +5% | 1 | 1 | 0% | 795 | 1,037 | +30% | 0 | 0 | — |
▸case-15 We need to check whether a user with a specific email exists in the database before proceeding. A developer wrote len(User.objects.filter(email=email)) > 0. Write the efficient Django ORM query that executes an SQL EXISTS clause. | pass→pass | 5,574 | 4,591 | -18% | 1 | 1 | 0% | 1,055 | 960 | -9% | 0 | 0 | — |
▸case-16 In a DRF InvoiceSerializer, we need a dynamically computed field is_overdue that compares due_date against today's date. Show how to declare this read-only calculated field on the serializer. | pass→pass | 7,794 | 6,319 | -19% | 1 | 1 | 0% | 1,543 | 1,417 | -8% | 0 | 0 | — |
▸case-17 In a Django view processing account balance transfers, we must lock the retrieved Account database row to prevent race conditions during updates. Write the ORM pattern using database transaction locking. | pass→pass | 9,764 | 8,439 | -14% | 1 | 1 | 0% | 1,952 | 1,826 | -6% | 0 | 0 | — |
▸case-18 We need to set global API rate limits in Django REST Framework: 100 requests per day for anonymous users and 1000 requests per day for authenticated users. Show the REST_FRAMEWORK settings snippet. | pass→pass | 3,674 | 3,693 | +1% | 1 | 1 | 0% | 760 | 918 | +21% | 0 | 0 | — |
▸case-19 In Django, a CourseEnrollment model links student and course. We want to ensure unique combinations of student and course at the database level using modern Meta.constraints. Show the Meta configuration. | pass→pass | 3,947 | 4,329 | +10% | 1 | 1 | 0% | 703 | 920 | +31% | 0 | 0 | — |
▸case-20 We are creating a simple webhook receiver function in Django REST Framework. Show how to decorate a function-based view to accept HTTP POST requests and handle DRF request parsing. | pass→pass | 9,678 | 7,632 | -21% | 1 | 1 | 0% | 1,904 | 1,580 | -17% | 0 | 0 | — |
▸case-21 We fetched 200 Task instances, updated their status attribute in memory, and want to save all changes in a single SQL UPDATE query. Show the Django ORM call to perform this batch update specifying status. | pass→pass | 2,581 | 3,116 | +21% | 1 | 1 | 0% | 468 | 609 | +30% | 0 | 0 | — |
▸case-22 We need a custom DRF permission class IsOwnerOrReadOnly that permits safe HTTP read operations for anyone but restricts write operations to object owners. Write the permission class implementation. | pass→pass | 5,987 | 5,808 | -3% | 1 | 1 | 0% | 1,189 | 1,183 | -1% | 0 | 0 | — |
▸case-23 We are writing a backend application using Flask and Flask-SQLAlchemy. Show how to define a database model User and query all records using the Flask-SQLAlchemy session. | pass→pass | 9,570 | 7,550 | -21% | 1 | 1 | 0% | 2,082 | 1,763 | -15% | 0 | 0 | — |
▸case-24 We are building an API endpoint with FastAPI and Pydantic v2. Show how to define a request body model UserCreate with field validation for password length. | pass→pass | 8,999 | 8,977 | -0% | 1 | 1 | 0% | 1,688 | 2,015 | +19% | 0 | 0 | — |
▸case-25 We need to configure Celery background tasks in a Python web app using Redis as broker and backend. Show the Celery configuration settings dictionary for connection URLs. | pass→pass | 8,393 | 9,888 | +18% | 1 | 1 | 0% | 1,503 | 2,159 | +44% | 0 | 0 | — |