Opened 8 years ago
Closed 8 years ago
#27268 closed Bug (fixed)
Regression on error message for invalid related fields lookup in QuerySet.get()
Reported by: | François Freitag | Owned by: | Mariusz Felisiak |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | get lookup related fields |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The expected error message for an invalid lookup in a get()
operation shoud look like:
Related Field got invalid lookup: foo
The current error message is:
TypeError: 'NoneType' object is not callable
Steps to reproduce:
models.py
class Tag(models.Model): text = models.CharField(max_length=100, unique=True) class Thing(models.Model): name = models.CharField(max_length=100) tags = models.ManyToManyField(Tag)
tests.py
def test_invalid_lookup(self): with self.assertRaisesMessage(TypeError, "Related Field got invalid lookup"): Thing.objects.get(tags__foo='bar')
It seems that the regression is introduced by https://github.com/django/django/commit/7aeb7390fc4231119494a9ebdee3c6ee0d5af053 and is only present on master.
Trac ticket related to the commit introducing the regression: https://code.djangoproject.com/ticket/26891
Change History (4)
comment:1 by , 8 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 8 years ago
Has patch: | set |
---|---|
Triage Stage: | Accepted → Ready for checkin |
Note:
See TracTickets
for help on using tickets.
PR