Code

Opened 6 years ago

Closed 6 years ago

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

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.

Attachments (0)

Change History (5)

comment:1 follow-up: Changed 6 years ago by mattrussell

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 6 years ago by jacob

  • Resolution set to invalid
  • Status changed from new to closed

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 6 years ago by carljm

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 5 years ago by mrmachine

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 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.