Opened 6 years ago

Closed 6 years ago

#29567 closed Bug (duplicate)

It raise FieldError when the F() function uses a forign key field.

Reported by: HongWeipeng Owned by: nobody
Component: Uncategorized Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by HongWeipeng)

class B(models.Model):
    name = models.CharField(max_length=10)

class A(models.Model):
    name = models.CharField(max_length=10)
    b = models.ForeignKey('B', on_delete=models.CASCADE)

And then:

A.objects.all().update(name=F('b__name'))

raise FieldError("Joined field references are not permitted in this query")
django.core.exceptions.FieldError: Joined field references are not permitted in this query

Change History (2)

comment:1 by HongWeipeng, 6 years ago

Description: modified (diff)

comment:2 by Dan Collins, 6 years ago

Resolution: duplicate
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top