Opened 14 years ago
Closed 14 years ago
#18002 closed Bug (fixed)
Typo in ReverseSingleRelatedObjectDescriptor
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.4 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
This code uses _field instead of field:
def __set__(self, instance, value):
if instance is None:
raise AttributeError("%s must be accessed via instance" % self._field.name)
Example:
>>> from django.contrib.auth.models import Permission
>>> Permission.content_type.__set__(None, "foo")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/brad/work/foo/.env/lib/python2.7/site-packages/django/db/models/fields/related.py", line 356, in __set__
raise AttributeError("%s must be accessed via instance" % self._field.name)
AttributeError: 'ReverseSingleRelatedObjectDescriptor' object has no attribute '_field'
Attachments (1)
Change History (5)
comment:1 by , 14 years ago
| Description: | modified (diff) |
|---|
by , 14 years ago
| Attachment: | attr-fix.diff added |
|---|
comment:2 by , 14 years ago
| Has patch: | set |
|---|---|
| Triage Stage: | Unreviewed → Ready for checkin |
comment:3 by , 14 years ago
| Needs tests: | set |
|---|---|
| Triage Stage: | Ready for checkin → Accepted |
| Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
What about a test?