Opened 10 years ago

Closed 9 years ago

Last modified 7 years ago

#9743 closed (worksforme)

Problem in admin when displaying foreignkey of a model that reference himself

Reported by: daniels Owned by: Jeremy Dunck
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords:
Cc: daniels@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:


class Client(models.Model):
  name = models.CharField()

class Module(models.Model):
  client = models.ForeignKey(Client)

class SuperModule(Module):
  sample = models.ForeignKey(Module)

If in the django.admin.contrib, we want to display SuperModule with a
list_display = ('name', 'client')
it will not work unless we remove the foreign key to Module.
It was not tested with the simple code above, but in our complete code.

After some investigation, I found a way where an error occured when doing 'as_sql()' on a
query_set. The error was about an extra parameter to avoid.update(). And some lines below,
the same function call but with a small difference in parenthesis and works OK.

Attachments (1)

query-dedupe.path (897 bytes) - added by daniels 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by daniels

Attachment: query-dedupe.path added

comment:1 Changed 9 years ago by Jacob

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:2 Changed 9 years ago by Jeremy Dunck

Needs tests: set
Owner: changed from nobody to Jeremy Dunck
Status: newassigned


It'd really help if you provided a full example of your models-- for example, related_name would be required. As long as you're there, maybe supply tests-- regressiontests/model_inheritance_regress would be the right place for it.

comment:3 Changed 9 years ago by Jacob

Resolution: worksforme
Status: assignedclosed

I can't reproduce this problem.

comment:4 Changed 7 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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