Opened 16 years ago

Closed 16 years ago

Last modified 13 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: no UI/UX: no

Description

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 16 years ago.

Download all attachments as: .zip

Change History (5)

by daniels, 16 years ago

Attachment: query-dedupe.path added

comment:1 by Jacob, 16 years ago

milestone: 1.1
Triage Stage: UnreviewedAccepted

comment:2 by Jeremy Dunck, 16 years ago

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

daniels,

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 by Jacob, 16 years ago

Resolution: worksforme
Status: assignedclosed

I can't reproduce this problem.

comment:4 by Jacob, 13 years ago

milestone: 1.1

Milestone 1.1 deleted

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