Opened 7 years ago
Closed 7 years ago
#29970 closed Bug (fixed)
Using cached_property on a model fails with: "Cannot use cached_property instance without calling __set_name__() on it."
| Reported by: | Collin Anderson | Owned by: | Sergey Fedoseev |
|---|---|---|---|
| Component: | Utilities | Version: | dev |
| Severity: | Release blocker | Keywords: | |
| Cc: | cmawebsite@…, Sergey Fedoseev, Thomas Grainger, Matt Westcott | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
With Python 3.6.7 (on Ubuntu 18.04), I'm getting this error for a fairly standard use of cached_property:
TypeError: Cannot use cached_property instance without calling __set_name__() on it.
class MyModel(models.Model):
@cached_property
def my_method(self):
return 'test'
I assume this was broken by #29478. Maybe Django's custom __new__ code for models breaks the __set_name__ hook?
Change History (6)
comment:1 by , 7 years ago
| Cc: | added |
|---|---|
| Severity: | Normal → Release blocker |
| Summary: | Cannot use cached_property instance without calling __set_name__() on it. → Using cached_property on a model fails with: "Cannot use cached_property instance without calling __set_name__() on it." |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 7 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
comment:3 by , 7 years ago
comment:4 by , 7 years ago
| Cc: | added |
|---|
Note:
See TracTickets
for help on using tickets.
Just noting, this is a Release Blocker for 2.2 (first release including 06076999026091cf007d8ea69146340a361259f8, fix from #29478).