Django Commenting framework and voting - django

I want to implement a commenting system for some pages by using the build-in commenting framework of Django.
The only addition to the default commenting framework is that other registered users can up/down vote comments (one time allowed indeed), just like Digg or Reddit style.
I have found RedditStyleVoting however it seems out of date and not really covering what I am looking for.
I will be grateful for any suggestion

You could use the django-voting application and allow vote for Comment objects.

Related

Edit form for django comments

I am using django comments apps to allow user to submit comments, but there is not any edit form for the comment. Does the comment app support an edit form or do I have to make one of my own.
Any help is appreciated.
I had the same issue, and have written a small portable app which aims to add edit functionality to the comments framework. Please note that it has not been tested, and it may be security issues with it. But you can check it out at github.
This isn't built in to the comment app so it's something you'll have to write yourself. You will need to consider how to confirm that the person requesting to edit a comment actually wrote the comment. This is ok if you are dealing with logged in users but will be difficult for anonymous comments.

What are the differences between django-tastypie and djangorestframework? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Why would you use one over the other, for exposing an API for your Django app?
http://pypi.python.org/pypi/djangorestframework/
http://pypi.python.org/pypi/django-tastypie
As the author of django-rest-framework, I've got an obvious bias ;) but my hopefully-fairly-objective opinion on this is something like:
TastyPie
As Torsten noted, you're not going to go far wrong with something written by the same peeps as the awesome django-haystack. From what I've seen on their mailing list Daniel Lindsey et al are super-helpful, and Tastypie is stable, comprehensive and well documented
Excels in giving you a sensible set of default behaviour and making building an API with that style incredibly easy.
Django REST framework
Gives you HTML browse-able self-describing APIs. (EG, see the tutorial API.) Being able to navigate and interact with the API directly in the browser is a big usability win.
Tries to stay close to Django idioms throughout - built on top of Django's class based views, etc... (Whereas TastyPie came along before Django's CBVs existed, so uses it's own class-based views implementation)
I'd like to think that the underlying architecture is pretty nicely built, decoupled etc...
In any case, both are good. I would probably characterise Tastypie as giving you a sensible set of defaults out of the box, and REST framework as being very nicely decoupled and flexible. If you're planning on investing a lot of time in the API, I'd def recommend browsing through the docs & codebase of each and trying to get a feel for which suits you more.
Obviously, there's also the 'Why TastyPie?' section in it's README, and the 'REST framework 3'.
See also Daniel Greenfeld's blog post on Choosing an API framework for Django, from May 2012 (Worth noting that this was still a few months before the big REST framework 2.0 release).
Also a couple of threads on Reddit with folks asking this same question, from Dec 2013 and July 2013.
Both are good choices.
For filters, tastypie is more powerful out-of-the-box. If you have a view that exposes a model, you can do Django-style inequality filters:
http://www.example.com/api/person?age__gt=30
or OR queries:
http://www.example.com/api/mymodel?language__in=en&language__in=fr
these are possible with djangorestframework, but you have to write custom filters for each model.
For tracebacks, I've been more impressed with django-rest-framework. Tastypie tries to email settings.ADMINS on exceptions when DEBUG = False. When DEBUG = True, the default error message is serialised JSON, which is harder to read.
EDIT Outdated answer, tastypie is not really maintained anymore. Use Django REST framework if you have to choose a framework to do REST.
For an overview about the actual differences between both of them you should read their documentation. They are both more or less complete and quite mature.
I personally tend to tastypie though. It seems to be easier to set it up. It's done from the same people which created django-haystack which is awesome and according to django-packages it is used more than Django REST framework.
It's worth noting that since this was first asked DRF has gone from strength to strength.
It's the more active of the two on github (both in terms of commits, stars, forks and contributors)
DRF has OAuth 2 support and the browsable API.
Honestly for me that last feature is the killer. Being able to point all my front-end devs at the browsable API when they aren't sure how something works and say 'Go play; find out' is fantastic.
Not least because it means they get to understand it on their own terms and know that the API really, definitely, absolutely does what the 'documentation' says it does. In the world of integrating with APIs, that fact alone makes DRF the framework to beat.
Well, Tastypie and DRF both are excellent choices. You simply can’t go wrong with either of them. (I haven’t worked on Piston ever; and its kind of not trending anymore now a days so won’t / can’t comment on it. Taken for Granted.).
In my humble opinion: Choice should be made on yours (and your tech team’s) skills, knowledge and capabilities. Rather than on what TastyPie and DRF offers, unless off-course you are building something really big like Quora, Facebook or Google.
Personally, I ended up starting working first on TastyPie at a time when I didn’t even know django properly. It all made sense at that time, only knowing REST and HTTP very well but with almost no or little knowledge about django. Because my only intention was to build RESTful APIs in no time which were to be consumed in mobile devices. So if you are just like ‘I happen to be at that time called django-new-bie’, Don’t think more go for TastyPie.
But if you have many years of experience working with Django, knows it inside out and very comfortable using advanced concepts (like Class Based Views, Forms, Model Validator, QuerySet, Manager and Model Instances and how all they interact with one another), **go for DRF. **DFR is bases on django’s class based views.
DRF is idiomatic django. Its like you are writing model forms, validators etc. (Well, idiomatic django is no where near to idiomatic python. If you are python expert but have no experience with Django then you might be having hard time initially fit into idiomatic django philosophy and for that matter DRF as well).
DRF comes with lots of inbuilt magic methods just like django. If you love the django magical methods and philosophy **DRF **is just for you.
Now, just to answer the exact question:
Tastypie:
Advantages:
Easy to get started with and provide basic functionalities OOB (out of the box)
Most of the time you won’t be dealing with Advanced Django concepts like CBVs, Forms etc
More readable code and less of magic!
If your models are NON-ORM, go for it.
Disadvantages:
Doesn’t strictly follow idiomatic Django (mind well python and django’s philosophies are quite different)
Probably bit tough to customize APIs once you go big
No O-Auth
DRF:
Follow idiomatic django. (If you know django inside out, and very comfortable with CBV, Forms etc without any doubt go for it)
Provides out of the box REST functionality using ModelViewSets. At the same time, provides greater control for customization using CustomSerializer, APIView, GenericViews etc.
Better authentication. Easier to write custom permission classes. Work very well and importantly very easy to make it work with 3rd party libraries and OAuth. DJANGO-REST-AUTH is worth mentioning LIBRARY for Auth/SocialAuthentication/Registration. (https://github.com/Tivix/django-rest-auth)
Disadvantages:
If you don’t know Django very well, don’t go for this.
Magic! Some time very hard to understand magic. Because its been written on top of django’s CBV which are in turn quite complex in nature. (https://code.djangoproject.com/ticket/6735)
Has steep learning curve.
Personally what would I use in my next project?
Now, I am no more a fan of MAGIC and Out-of-box functionalities. Because all they come at a *great cost. * Assuming I have all choices and control over project time and budget, I would start with something light weight like RESTLess (https://github.com/toastdriven/restless) (created by the creator of TastyPie and django-haystack (http://haystacksearch.org/)). And for the same matter probably/definately choose the lightweight web framework like Flask.
But why? - More readable, simple and manageable idiomatic python (aka pythonic) code. Though more code but eventually provide great flexibility and customization.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
What if you have only no choice but Django and one of TastyPie and DRF?
Now, knowing the Django reasonably well, I will go with **DRF. **
Why? - idiomatic djagno! (I don’t love it though). Better OAuth and 3rd party integration (django-rest-auth is my favorite).
Then why you chose the DRF/TastyPie at first place?
Mostly I have worked with startups and small firms, which are tight on budget and time; and need to deliver something quick and usable. Django serve this purpose very well. (I am not at all saying that django is not scalable. There are websites like Quora, Disquss, Youtube etc run on it. But all it require time and more then average skills)
I hope, it will help you to take better decision.
Other references -
1. The State of Tastypie (http://toastdriven.com/blog/2014/may/23/state-tastypie/)
2. What are the differences between django-tastypie and djangorestframework? (What are the differences between django-tastypie and djangorestframework?)
Having used both, one thing that I liked (preferred) about Django Rest Framwork is that is is very consistent with Django.
Writing model serializers is very similar to writing model forms. The built in Generic Views are very similar to Django's generic views for HTML.
Django-tastypie is no longer maintained by it's original creator and he created a new light weight framework of his own.
At present you should use django-rest-framework with django if you are willing to expose your API.
Large corporations are using it. django-rest-framework is a core member of django team and he get funding to maintain django-rest-framework.
django-rest-framework also have huge number of ever growing 3rd arty packages too which will help you build your API's more easily with less hassles.
Some part of drf will also be merged in django proper.
drf provide more better patterns and tools then django-tastypie.
In short it's well designed, well maintained, funded, provide huge 3rd party apps, trusted by large organisations, easier and less boilerplate etc over tastypie.

Comment and Rating system for Django

I am new to Django, I don't know a lot of them.
I am trying to build a comment and rating system for a blog in Django. There are some apps that I can use to achieve this(Comment and Rating)?
Please let me know.
Best Regards,
At Eldarion, we've ended up building and using dialogos for all our comments on sites: https://github.com/eldarion/dialogos
And for ratings are extending agon: https://github.com/eldarion/agon
While agon was originally just about giving people points, it can also be used to give arbitrary objects points and this can be used for both voting and rating.
Both of these apps will have extensive use in the next release of Pinax.
The django.contrib.comments that comes with django works well, even if it is rather simplistic. Seems to be extendable for more elaborate needs, though.

What's a good open source django project to learn from?

What is a good django open source app that I can learn from? Something that follows best practices, and covers the majority of features and isn't overly complicated?
This would depend on your current level of knowledge of python and django.
If you are just starting to use django, I suggest you take a look in django documentation. It is well specified and clear. If you have some project in mind, start working on it while looking up for best practices about specific parts. For python coding style try to follow the pep 8 style guide.
If you already have done some work with django there are many sites lie these:
http://djangopackages.com/categories/apps/
http://www.django-apps.com/
What I do nowdays is look into django contrib apps (admin, auth, comments, flatpages), which are built based on the rest of django. This gives the best ways on how to write my apps.
Following the django comments framework (object independent), I am working on an app django-valuate (object independent attachment of ratings, likebuttons etc. through template tags)
These are some of my views. I have also starred this question, as I would like to know about some different perspectives and if mine are sound.
I've found djangobb (www.djangobb.org) to be a complete application, production quality and relatively simple. I use it as a base for my application which has nothing to do with forums and bb.
cloc output: only 3000 lines of python code in 30 files, another 2900 lines of templates html
I do not think there would be any one specific app that would cover all/most features of Django since the concept of the Django app itself is to perform specific/related functionality.
Having said that, a popular Django app is django-registration. Its popularity stems from the obvious requirement of most webapps to have User authentication and also its extremely easy to integrate with a Django project.
The best approach perhaps would be to keep trying the tons of open source Django apps available on the net. You can browse through http://www.djangopackages.com/ and http://www.django-apps.com/ to start getting your hands dirty.
snipt.net, a code sharing site:
https://github.com/lionburger/snipt
Review Board, a code review web app
https://github.com/reviewboard/reviewboard/tree/master/reviewboard
rietveld, another code review on app engine, by GVR himself. You need to know a bit of Django before digging into this source code since the Django models don't work on App Engine, GAE db model is used instead.
http://code.google.com/p/rietveld/source/browse/#svn%2Ftrunk

Django Comments and Rating Systems

I am looking for a blogging and comments system that can smoothly integrate with my Django sites. I've found there is a lot on the Net and got lost a bit, and I don't have much experience on this. Hope you guys can give me some suggestions.
Here are the things that I would like to have:
Tag Clouds
Articles Archive (by months/by years)
Articles Rating (e.g. with Stars or customize icons)
Comments to the particular Topic/Articles
Sub-Comments of a particular comments (i.e. following up comments)
Blogs/Articles Searching
Able to relate other articles that is relevant (i.e. follow up Articles)
Pagination of the comments if get too long
OpenIDs supports (e.g. facebook, hotmail, blogger, twitter...etc)
Support login before user can comments
Able to retrieve Blogs' Header and customized the display order
Able to subscribe this article to RSS
Able to Email this to friends (this may not belongs to the comments system)
If I missed some common functions, please let me know. The comments system I am looking for should do most jobs that those popular comments system should do on the web, e.g. WordPress.
Thank you so much everyone. Have a nice day.
I myself really like django-threadedcomments. It supports threaded commenting like what you would see in Disqus.
i heard django-comment-utils is quite good. - may you test it :)