django-favorites /

Filename Size Date modified Message
31 B
7.5 KB
0 B
145 B
1.6 KB
748 B
Django Favorites

My generic favorites framework for Django fork.
This fork differentiates from it's parent mainly in front-end: 
- it uses a single view to process ajax fav/unfav (like/unlike) action
- has a single templatetag to render a fav/unfav button
- includes a jquery function to handle the ajax button click

My fork uses the ajax_login_required decorator from


- ./ install
  or copy /favorites to your project directory
- add 'favorites' to your INSTALLED_APPS
- add favorites.urls to your
- copy javascript /static/js/jquery.django-favorites.js file to your media folder and include it in your template. It depends on Jquery.

Basic usage examples:

#Render a fav/unfav button in your templata

{% load favorite_tags %}
{% for post in blog_posts %}
  <h3>{{ post.title }}</h3>
  <p>{{ post.content }}</p>
  <div class="actions">{% if user.is_authenticated %}{% fav_item post user %}{% endif %}</div>
{% endfor %}

#Get all favorites for user

favs =  Favorite.objects.favorites_for_user(user)

#Get only blogpost favorites for user

content_type = get_object_or_404(ContentType, app_label='myblogapp', model='blogpost')
favs = Favorite.objects.favorites_for_user(user).filter(content_type=content_type)

You can configure the text messages overriding these values in your
or override the templatetag

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.