Просмотр исходного кода

Correctly delete related objects.

Ralfp 12 лет назад
Родитель
Сommit
c7231c25da
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      misago/models/threadmodel.py

+ 2 - 2
misago/models/threadmodel.py

@@ -73,7 +73,7 @@ class Thread(models.Model):
     last_poster_name = models.CharField(max_length=255, null=True, blank=True)
     last_poster_slug = models.SlugField(max_length=255, null=True, blank=True)
     last_poster_style = models.CharField(max_length=255, null=True, blank=True)
-    participants = models.ManyToManyField('User', related_name='+')
+    participants = models.ManyToManyField('User', related_name='private_thread_set')
     moderated = models.BooleanField(default=False)
     deleted = models.BooleanField(default=False)
     closed = models.BooleanField(default=False)
@@ -200,7 +200,7 @@ move_forum_content.connect(move_forum_content_handler, dispatch_uid="move_forum_
 def delete_user_handler(sender, instance, using, **kwargs):
     from misago.models import User
     if sender == User:
-        for thread in user.participants_set:
+        for thread in instance.private_thread_set.all():
             thread.participants.remove(instance)
             if not thread.participants.count():
                 thread.delete()