Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommentFlag incompatible with user-defined comment model #1

Open
ukch opened this issue Apr 2, 2013 · 4 comments
Open

CommentFlag incompatible with user-defined comment model #1

ukch opened this issue Apr 2, 2013 · 4 comments

Comments

@ukch
Copy link

ukch commented Apr 2, 2013

As an example, in models.py:

class SpecialComment(comments.models.BaseCommentAbstractModel):
    # Define fields and stuff here
    pass

If we set this as our model, by overriding get_model and CommentForm.get_comment_model we can create comments fine, but if we try to delete them, we get this error:

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)
  ...
  File "/usr/lib/python2.7/dist-packages/django/contrib/comments/views/moderation.py", line 117, in perform_delete
    flag    = comments.models.CommentFlag.MODERATOR_DELETION
  File "/usr/lib/python2.7/dist-packages/django/db/models/manager.py", line 134, in get_or_create
    return self.get_query_set().get_or_create(**kwargs)
  File "/usr/lib/python2.7/dist-packages/django/db/models/query.py", line 447, in get_or_create
    obj = self.model(**params)
  File "/usr/lib/python2.7/dist-packages/django/db/models/base.py", line 355, in __init__
    setattr(self, field.name, rel_obj)
  File "/usr/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 366, in __set__
    self.field.name, self.field.rel.to._meta.object_name))
ValueError: Cannot assign "<SpecialComment object>": "CommentFlag.comment" must be a "Comment" instance.

The only way I can think of to avoid this issue is to completely rewrite CommentFlag and the deletion method, thus pretty much reinventing the wheel.

@ukch
Copy link
Author

ukch commented Apr 3, 2013

One possible solution is to allow the definition of a custom CommentFlag object via a get_comment_flag function or similar.

@ghost
Copy link

ghost commented Nov 27, 2018

5 years later, still no fix.

@charettes
Copy link
Member

@zmrenwu this is a volunteer project. If this issue is has not been fixed in the last 5 years it's probably because it was not considered critical enough for someone to dedicate time fixing it. If it is to you I encourage you to give a try at submitting a patch for it. Complaining about unresolved issues without providing a solution is not going to get it fixed by itself or encourage someone to work towards it.

@ghost
Copy link

ghost commented Nov 27, 2018

Sorry, I don't mean to complain, just a banter. I encounter this issue recently. I am trying to fix it. But if an issue haven't have any responses and discussions for 5 years, I doubt if it will be reviewed or merged by the maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants