honzakral / django-threadedcomments

django-threadedcomments is a simple yet flexible threaded commenting system for Django.
BSD 3-Clause "New" or "Revised" License
622 stars 165 forks source link

updating comments correctly #63

Closed SushiTee closed 9 years ago

SushiTee commented 9 years ago

When doing a comment on a comment the parent doesn't get updated properly with Django 1.8 This change seems to fix it. Hope it's correct.

Internal Server Error: /c/post/
Traceback (most recent call last):
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/views/decorators/http.py", line 45, in inner
    return func(request, *args, **kwargs)
  File "/usr/teerace/web/src/django-comments/django_comments/views/comments.py", line 124, in post_comment
    comment.save()
  File "/usr/teerace/web/src/django-threadedcomments/threadedcomments/models.py", line 40, in save
    ThreadedComment.objects.filter(pk=self.parent_id).update(last_child=self)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/db/models/query.py", line 563, in update
    rows = query.get_compiler(self.db).execute_sql(CURSOR)
  File "/usr/teerace/web/src/django-cachalot/cachalot/monkey_patch.py", line 108, in inner
    return original(compiler, *args, **kwargs)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 1048, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/usr/teerace/web/src/django-cachalot/cachalot/monkey_patch.py", line 45, in inner
    out = original(compiler, *args, **kwargs)
  File "/usr/teerace/web/src/django-cachalot/cachalot/monkey_patch.py", line 90, in inner
    return execute_query_func()
  File "/usr/teerace/web/src/django-cachalot/cachalot/monkey_patch.py", line 85, in <lambda>
    execute_query_func = lambda: original(compiler, *args, **kwargs)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 829, in execute_sql
    cursor.execute(sql, params)
  File "/usr/teerace/web/src/django-cachalot/cachalot/monkey_patch.py", line 124, in inner
    out = original(cursor, sql, *args, **kwargs)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/teerace/web/local/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
ProgrammingError: can't adapt type 'Comment'
honzakral commented 9 years ago

Thanks for the patch!