Opened 3 years ago

Closed 3 years ago

#18002 closed Bug (fixed)

Typo in ReverseSingleRelatedObjectDescriptor

Reported by: Bradley Ayers <bradley.ayers@…> 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 aaugustin)

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)

attr-fix.diff (652 bytes) - added by ptone 3 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by aaugustin

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Changed 3 years ago by ptone

comment:2 Changed 3 years ago by ptone

  • Has patch set
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 3 years ago by claudep

  • Needs tests set
  • Triage Stage changed from Ready for checkin to Accepted
  • Type changed from Uncategorized to Bug

What about a test?

comment:4 Changed 3 years ago by claudep

  • Resolution set to fixed
  • Status changed from new to closed

In [17904]:

Fixed #18002 -- Fixed typo in attribute name in ReverseSingleRelatedObjectDescriptor.

Note: See TracTickets for help on using tickets.
Back to Top