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

The updown object doesn't removed after related object was deleted #33

Open
agusmakmun opened this issue Aug 13, 2018 · 2 comments
Open

Comments

@agusmakmun
Copy link
Contributor

agusmakmun commented Aug 13, 2018

hello @dbanck, I have a little problem. Let say, I have a Post model:

@python_2_unicode_compatible
class Post(TimeStampedModel):
    author = models.ForeignKey(User, on_delete=models.CASCADE)
    title = models.CharField(_('Title'), max_length=200)
    ....
    rating = RatingField(can_change_vote=True)

After I deleted the object of post, and I check at updown.models it still exist. But the content_object is blank. Why the Vote object doesn't deleted also?

>>> from updown.models import Vote
>>> 
>>> Vote.objects.filter(content_type__model='post', user__username='yogesh_pagal')
<QuerySet [<Vote: yogesh_pagal voted 1 on None>]>
>>> 
>>> v = Vote.objects.filter(content_type__model='post', user__username='yogesh_pagal').first()
>>> v.content_object
>>> 

If I check at these lines, the content_type field already using on_delete=models.CASCADE.

content_type = models.ForeignKey(ContentType, related_name="updown_votes", 
                                 on_delete=models.CASCADE)

or, maybe this case?

content_object = GenericForeignKey()

should change to:

content_object = GenericForeignKey('content_type', 'object_id')

I was tried this method, but still doesn't work properly.

agusmakmun added a commit to agusmakmun/django-updown-ratings that referenced this issue Aug 13, 2018
@dbanck
Copy link
Contributor

dbanck commented Aug 14, 2018

Hi there again!

Thanks for the PR! But I'm not entire sure if the change fixes your problem. Did you try it and it's working properly?

@agusmakmun
Copy link
Contributor Author

hello @dbanck, not yet. I am also looking a solution for this issue.

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

No branches or pull requests

2 participants