Coder Social home page Coder Social logo

zalew / django-favorites Goto Github PK

View Code? Open in Web Editor NEW

This project forked from olomix/django-favorites

7.0 3.0 1.0 102 KB

Generic favorites app for django with some more utilities that make it a bit more plugable

Home Page: http://apgwoz.com

License: GNU Lesser General Public License v3.0

JavaScript 6.12% Python 93.88%

django-favorites's Introduction

================
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

Dependencies:
My fork uses the ajax_login_required decorator from https://bitbucket.org/zalew/django-annoying


Installation

- ./setup.py install
  or copy /favorites to your project directory
- add 'favorites' to your INSTALLED_APPS
- add favorites.urls to your urls.py
- 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 settings.py
https://github.com/zalew/django-favorites/blob/master/favorites/settings.py
or override the templatetag
https://github.com/zalew/django-favorites/blob/master/favorites/templates/favorites/fav_item.html


django-favorites's People

Contributors

apg avatar idris avatar zalew avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.