Opened 11 years ago

Closed 11 years ago

Last modified 8 years ago

#8738 closed (invalid)

Compatability with contenttypes

Reported by: mattrussell Owned by: nobody
Component: contrib.comments Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Just tried upgrading to latest, and get an exception:

FieldError - "Cannot resolve keyword 'object_id' into field"
Exception Location: /usr/local/lib/python2.5/site-packages/django/db/models/sql/ in setup_joins, line 1248

This is running off trunk (r8726)
I notice that comments have an object_pk field, should that be object_id? Or is there more needed than the SQL provided
in the upgrade sql snippet?

This is when using comments with django.contrib.contenttypes.generic.GenericRelation and friends.

Change History (5)

comment:1 Changed 11 years ago by mattrussell

I've managed to work around this by assigning my generic relations like this:

class MyModelWithCommentsField(models.Model):
    comments = generic.GenericRelation(Comment, object_id_field="object_pk")

comment:2 in reply to:  1 Changed 11 years ago by Jacob

Resolution: invalid
Status: newclosed

Replying to mattrussell:

I've managed to work around this by assigning my generic relations like this:

That's not a work around; that's correct code.

comment:3 Changed 11 years ago by Carl Meyer

The point is that contrib.comments chooses to use "object_pk" in place of "object_id", which is the default for contrib.contenttypes.generic, meaning you always have to give the object_id_field parameter explicitly. Not a bug, really, but annoying for no apparent reason.

comment:4 Changed 10 years ago by Tai Lee

Agree, annoying for no apparently reason. Made worse by the documentation not mentioning that object_id_field is an argument to GenericRelation or that the comments app uses a field name that is different to the default. I think this ticket should be re-opened with intent to fix with an addition to the documentation.

comment:5 Changed 8 years ago by Jacob

milestone: 1.0

Milestone 1.0 deleted

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