django-machina
                                
                                 django-machina copied to clipboard
                                
                                    django-machina copied to clipboard
                            
                            
                            
                        reply to post and tree-like organization of posts
Just checking if I have missed something obvious, is is true that reply in machina always replies to the topic, not particular post? In another word,
- how can I reply to a particular post (and notify the author of the post, in addition to the topic poster)?
- how can I organize the post in a tree-like structure, like what quora or disqus do?
That would appear to be the case. There isn't a 'reply to post' feature like on most forums.
I too was looking for django forum software that did both the things you're asking about too ...
I can confirm that django-machina does not support this feature. It is however possible to extend Post to support it. It is a lot of work but the following are the essential steps:
- 
Extend the entire forum_conversationapp as described in the documentation.
- 
extend Postand add areply-tofield.
from machina.apps.forum_conversation.abstract_models import AbstractPost
class Post(AbstractPost):
    reply_to = models.ForeignKey(
        'Post', related_name='replies', on_delete=models.CASCADE
    )
- Extend the PostCreateView(optional, but here is how to included the quoted text in the new reply)
from machina.apps.forum_conversation.views import PostCreateView as BasePostCreateView
def quote_text(text):
    lines = ['> ' + x for x in text.raw.splitlines()]
    return '\n'.join(lines) + '\n\n'
class PostCreateView(BasePostCreateView):
    def get_post_form_kwargs(self):
        kwargs = super().get_post_form_kwargs()
        
        if 'reply_to' in self.request.GET:
            try:
                post = Post.objects.get(pk=self.request.GET['reply_to'])
                kwargs['reply_to'] = post
                kwargs['initial'] = {'content': quote_text(post.content)}
            except Exception as e:
                logger.warning(e)
        else:
            kwargs['reply_to'] = None
        return kwargs
- Similarly, the the PostForm, you will need to savereply_totoPost.
- Then, in the template, you will have to carefully display posts depending on reply_toofpost. You can display everything sequencitially but markingreply_to, or display in a tree structure, basically running a for loop that lists all replies....