20
Jul
stored in: General and tagged:
In using django-discussion, I found a small bug. If I have a custom defined primary key for an object which accepts comments, the code from SVN doesn’t work, I get an error like “No attribute ‘id’ for ‘Model'”. This is because it is trying to use the django-set ID for the model. Typically, when you define a model in Django, it’ll automatically create an ‘ID’ field, which acts as the primary key for the model. If you define your own primary key, the fix is really easy. Granted, this is just for posting, I haven’t tested anything beyond that (give me time…).
On line 21 of models.py, change:
object_id=obj.id
to
object_id=obj._get_pk_val
Easy as that.