jazzband / jazzband/django-model-utils

AttributeError: 'DescriptorWrapper' object has no attribute 'get_queryset'

Open
#508 3 comments 3 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.8k
Forks
374
PR merge metrics
No merged PRs in 30d

Description

## Problem

When accessing model's field, `DescriptorWrapper` returns itself as an object, which breaks the logic. See more in examples.

## Environment

- Django Model Utils version: 4.1.1
- Django version: 3.2.8
- Python version: 3.9.1
- Other libraries used, if any:

## Code examples

```py
class A(models.Model):
pass

class B(models.Model):
x = models.ForeignKey(A, on_delete=models.CASCADE)

tracker = FieldTracker(fields=["x"])

# This throws
B.x.get_queryset()
```

Contributor guide

Open the contributing guide

Research direction

Start with the provided B.x.get_queryset() reproduction and inspect how FieldTracker(fields=["x"]) affects the ForeignKey attribute through DescriptorWrapper. Confirm the failure on the stated Django and django-model-utils versions, then verify that accessing B.x no longer returns a DescriptorWrapper that lacks get_queryset.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.