Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Internet > HTTP (WWW)

    django-likeable 0.0.1

    Download button

    No screenshots available
    Downloads: 144  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Thane Thomson | More programs
    The Apache License 2.0 / FREE
    May 23rd, 2011, 13:26 GMT
    ROOT / Internet / HTTP (WWW)

     Read user reviews (0)  Refer to a friend  Subscribe

    django-likeable description

    Simple Django app to facilitate "liking" of any content type

    django-likeable is a Django app that adds "liking" functionality which aims to be scale-friendly (see django-nonrel) by favouring abstract classes instead of direct class inheritance when facilitating liking. Allows liking of any model registered with the contenttypes framework.

    Note that this app is not yet tested at scale, but will be at some point in the near future. In the meantime, it simply adds "liking" functionality to your models.

    Quick Installation

    1. Add the django-likeable app to your Python path.
    2. Add likeable to your list of INSTALLED_APPS in your project settings.
    3. Create your likeable model:

    from likeable import Likeable
    from django.contrib.auth.models import User

    class BlogEntry(Likeable):

     author = models.ForeignKey(User)
     content = models.TextField()
     created = models.DateTimeField(auto_now_add=True)

    class BlogEntryComment(Likeable):

     entry = models.ForeignKey(BlogEntry)
     author = models.ForeignKey(User)
     content = models.TextField()
     created = models.DateTimeField(auto_now_add=True)


    Liking Content Manually

    You can use the provided Likeable.like function to automatically like a particular object by a given user, such as:

    from likeable import Like
    from models import BlogEntry, BlogEntryComment
    from django.contrib.auth.models import User

    ...

    # harry posts a blog entry
    harry = User.objects.create(username='harry')
    blog_entry = BlogEntry.objects.create(author=harry, content="This is my first post.")

    ...

    # sally likes the blog entry
    sally = User.objects.create(username='sally')
    blog_entry.like(sally)


    Liking Content Via Provided Views

    Make sure your project's urls.py file looks something like this:

    from django.conf.urls.defaults import patterns, include, url

    urlpatterns = patterns('',

     # ...

     # add django-likeable's urls
     url(r'^like/', include('likeable.urls')),

     # ...
    )


    Enabled URLs

    like//

    Auto-detects whether a request comes in via a plain GET request or an AJAX request, and handles it according to the following two views.

    like/noajax/< content_type_id >/< object_id >

    Attempts to like the object whose content type ID is and primary key is (both positive integers). This function automatically attempts to redirect the user to the referring URL after liking the given object. If no object matching the given criteria is found, an HTTP 404 error will be generated.

    like/ajax/< content_type_id >/< object_id >

    Attempts to like the object whose content type ID is < content_type_id > and primary key is < object_id > (both positive integers). This function returns a JSON object of the format {'success': true} upon success. If no object matching the given criteria is found, an HTTP 404 error will be generated.

    Other Batteries Included

    likeable.views.get_like_view_params(obj)

    obj must be any object registered with the contenttypes framework. On success, this shortcut function will return a tuple containing first the content type ID primary key as well as the object's primary key, which can then simply be passed to one of the django-likeable views.


    Product's homepage

    Requirements:

    · Python
    · Django

      


    TAGS:

    content type | Django liking | Django | liking | content

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM