django / django-contrib-comments

BSD 3-Clause "New" or "Revised" License
619 stars 197 forks source link

No Multiple Database Management #47

Closed gustavklopp closed 9 years ago

gustavklopp commented 9 years ago

When using several databases (which is allowed by Django : https://docs.djangoproject.com/en/1.7/topics/db/multi-db/) , django-contrib-comments raises an error when trying to post a comment.

Comment post not allowed (400) 
No object matching content-type 'MyModel.mymodeltable' and object PK '1' exists

Problem with the query inside post_comment function where there's no taking into account of multiple databases by a using(database) property? (as defined in the django docs to make a query with multiple databases: https://docs.djangoproject.com/en/1.7/topics/db/multi-db/#manually-selecting-a-database )

claudep commented 9 years ago

I cannot reproduce this issue, are you sure your database routers are properly defined? A sample project might help debug this issue.

gustavklopp commented 9 years ago

I've only used using(my_database). (Using only that works when I'm trying to fetch my data from my database.)

Do I need to use a "Database router"? https://docs.djangoproject.com/en/1.7/topics/db/multi-db/#using-routers

Could you describe shortly how to set it up for django-contrib-comments?

claudep commented 9 years ago

django-contrib-comments cannot magically guess the database your object is located in. So you should either configure database routers or provide your own custom post_comment view that will compute or hard-code the database alias, then call the django-contrib-comments post_comment view providing a non-null using argument. I think the first solution is preferable if possible.