Total_score = F('upvotes') - F('downvotes'), # return round(sign * order + seconds / 45000, 7) # sign = 1 if score > 0 else -1 if score < 0 else 0 # """Returns the number of seconds from the epoch to date.""" # epoch = datetime(1970, 1, 1, tzinfo=pytz.utc) This is (part of) my views.py, which doesn't work and is missing a lot of stuff after line 33, though the annotate function for getting the score (upvotes - downvotes) and sorting on it, did work: import pytzįrom django.shortcuts import render, get_object_or_404, redirectįrom import reverseįrom import Paginator, EmptyPage, PageNotAnIntegerįrom django.http import HttpResponseRedirectįrom import login_requiredįrom import ContentType So my question is: how would one go about recreating the reddit sort algorithm in Django? However, I haven’t been able to get very far. So in order to sort on it, I’ve been trying to recreate the sorting algorithm in a query string, using annotate() and aggregate() functions. I was able to set it up as a property in the model, but that does not get saved to the database, which means you cannot sort on it. My next step is to implement the reddit sorting. Join us in IRC #reddit-help on a learning project, I thought it’d be fun to create a kind of reddit clone in Django. Be sure to check the information in the sidebar and the FAQ!.The lightbulb icons next to usernames indicate people who have demonstrated a history of providing useful and helpful answers in this subreddit. /r/aboutreddit - for submissions about Reddit./r/FindASubreddit - Looking for a subreddit on a particular topic but don't know where to start?./r/FindAReddit - Looking for a subreddit on a particular topic but don't know where to start?./r/ideasfortheadmins - suggestions to improve Reddit./r/modclub A place for mods of communities with 100 or more users to hang out./r/modsupport - a point of contact for moderators to discuss issues with reddit admins, mostly about mod tools./r/modhelp - Help for questions about moderation./r/AskModerators - for general questions aimed at moderators of reddit./r/needamod - Need help moderating a reddit? Want to volunteer?./r/adoptareddit - Give away or acquire an unused subreddit. /r/redditrequest - Request to moderate an abandoned subreddit or request a subreddit be unbanned./r/Enhancement - Reddit Enhancement Suite (RES) from /u/honestbleeps./r/RedditMobile - Official reddit mobile apps./r/goldbenefits - Check out new gold features and reddit gold partners./r/Bugs - If you have found a possible bug in reddit.See the FAQ for more information.įor other questions not specific to reddit, try: If you have tried the above and your content still does not show, please contact a moderator in the reddit where you're having problems. If you are a new user/trying to submit a post in a reddit you have not submitted to before, please take some time to first participate in that reddit (browse, upvote content/comments etc). New to reddit? click here! reddit status - status page for checking site health Check the FAQ or the Reddit Help Center to see if your question has already been answered. For your questions about Reddit only, please.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |