Opened 16 years ago

Closed 16 years ago

Last modified 13 years ago

#8738 closed (invalid)

Compatability with contenttypes

Reported by: mattrussell Owned by: nobody
Component: contrib.comments Version: dev
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

Description

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/query.py 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 by mattrussell, 16 years ago

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")

in reply to:  1 comment:2 by Jacob, 16 years ago

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

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 by Tai Lee, 15 years ago

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

milestone: 1.0

Milestone 1.0 deleted

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