Okay, I'm pretty new to django (and coding in general), so please bear with 
me. I'm trying to create the most basic features of a forum, and I had a 
few questions about how to go about doing this. So far, I've set up a 
post-only (i.e., no way to comment) project that consists of a single app 
using only class-based, generic views: a list view for the "feed" of posts, 
and detail, create, and delete views for individual posts.


What I'm trying to do next is get comments working, more or less from 
scratch. I've considered alternatives to this, but the django comments 
framework is (from what I understand) set to become deprecated in the next 
release, and there doesn't seem to be a third-party app that is 
well-regarded and regularly updated. (I would ultimately like to include 
django-mptt (which takes the hard part out of implementing a modified 
pre-order traversal tree) in order to create a nested comment system, but 
it seems like the first step is getting a regular comment system set up.)


My first question is whether it seems like I'm thinking about this whole 
thing in a reasonable way based on the last two paragraphs (I don't have 
any friends or acquaintances who code that I can run things like this by, 
and sometimes I wonder if my dazed wanderings are leading me in exactly the 
wrong direction).


If I am, my next question is this: what is the best way to implement a 
(detail-type) view that will let me display a single posting and all of the 
comments that are related to that posting (which I assume I should do via 
foreign key)? If possible, I'd like to do this via a (presumably 
non-generic) class-based view, since I get the sense from reading things 
from people who really know django that, in general, CBVs should be favored 
over functional views (being this new to the framework, I have to take a 
lot of things on faith).


Tangential to this question is how to access a post's comments in a 
template. Would something like this suffice?


    {% for comment in posting.comment_set.all() %}

        <ul>

          <li>{{ comment }}</li>

          <li>{{ comment.user }}</li>

        </ul>


And if I later want to sort comments based on an algorithm that includes a 
few pieces of information, is the best place to put this code in the 
comments model as a method?


Finally, it seems that in system of nested comments, where you can reply to 
not only the post but also to any comment at any level, it would not make 
sense to implement a view to create a comment in django alone. It would 
seem necessary to use some Javascript to create "Reply" links that, on 
click, open up to a form with a text area and "Submit" button. My question, 
then, is whether it makes sense to use a django view for this at all, or 
whether this would be better done entirely in some AJAX framework.


(Oh, one more thing: I'm holding off on implementing the actual django user 
authentication app until I've got this stuff worked out, because I figure 
it'll be easy enough to go back and add it in afterward. Is this a mistake?)


Okay, I think that's all I've got for now. As you can see, I might be in 
over my head here, but it's important to me to do what I'm trying to do, 
and I can't afford to have someone do it for me. Any tips, thoughts, 
reprimands, advice, or pointings-in-the-right-direction are appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to