Skip to main content

An easy way to add feedback'like/dislike' to any of your models.

Project description

django-like-system

An easy way to add feedback "like/dislike" to any of your models.

Requirements

  • Django 2.2+
  • jQuery

Installation

pip install django-like-system

Usage

  • Add 'django-like-system' to your INSTALLED_APPS:

    INSTALLED_APPS = (
    ...
    'django-like-system',
    ...
    )
    
  • You must add LIKES_OBJS_DICT dictionary to your settings.py file. The keys in this dictionary - are the path to your model, value - list with class name:

    LIKES_OBJS_DICT = {'example.models': ['Test', 'Test2'],
                       'example1.models': ['Test3']}
    
  • Your models to which you want to attach as feedback 'like/dislike' should inherit class LikesTarget:

    from like_system.models import LikesTarget
    
    # Create your models here.
    
    class Test(LikesTarget):
        headline = models.CharField(max_length=500)
    
    class Test1(LikesTarget):
      headline1 = models.CharField(max_length=500)
    
  • Add jQuery and app.js in your html template:

    <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
    <script src="{% static 'like_system.js' %}"></script>
    
  • Your buttons like and dislike should have class css class 'like' and 'dislike'. Like and dislike counters should have class 'likecount' and 'dislikecount'. For live mapping, wrap the entire construction in a div with css class 'likesystem':

    {% for obj in my_list %}
    <div class='likesystem'>
      <p>{{obj.headline}}-{{obj.likesystem.total}}</p>
      <span class='likes' data-id={{obj.id}} data-type='test'>like</span>
      <span class='countlikes'>{{obj.likesystem.likes.count}}</span>      
      <span class='dislikes' data-id={{obj.id}} data-type='test'>dislike</span>
      <span class='countdislikes'>{{obj.likesystem.dislikes.count}}</span>
    </div>
    {% endfor%}
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-like-systems-0.0.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_like_systems-0.0.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file django-like-systems-0.0.1.tar.gz.

File metadata

  • Download URL: django-like-systems-0.0.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.1

File hashes

Hashes for django-like-systems-0.0.1.tar.gz
Algorithm Hash digest
SHA256 1ae2caa045839c711ecf1669f915cc4ddae0bc8ae46d4461c65674ea68ef4c2a
MD5 79c1479d1ffba1917b0a7ff43219501a
BLAKE2b-256 5070344588f79123dc9f565d03393140de8f043e10955889da72e3c4976df9ac

See more details on using hashes here.

File details

Details for the file django_like_systems-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_like_systems-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.1

File hashes

Hashes for django_like_systems-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17338519d09002a6ad6551126d0d8651946372e619d52d893bf3b71c32a809ef
MD5 0651afc6d1bbe5e75f73c861d8a8c600
BLAKE2b-256 ffa7e85675a19482c3019761a14d4548240bf7b4921d5d63e5fabe0c281eaeb9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page