{ "info": { "author": "Oleg Kleschunov", "author_email": "igorkleschunov@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "Operating System :: OS Independent", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "==============================\ndjango-ok-likes |PyPI version|\n==============================\n\n|Build Status| |Code Health| |Python Versions| |Requirements Status| |license| |PyPI downloads| |Coverage|\n\n``django-ok-likes`` is a liking app for Django, which allows users \"like\" and \"unlike\" any model instance. All functionality provides through `django-rest-framework`_ API views. Template tags and jinja's global functions provide the ability to see who liked an object, which objects were liked by current user and count of likes for a given object.\n\nInstallation\n============\n\nInstall with pip:\n\n.. code:: shell\n \n pip install django-ok-likes\n\n\nUpdate INSTALLED_APPS:\n\n.. code:: python\n\n INSTALLED_APPS = [\n ...\n 'likes',\n 'rest_framework',\n ...\n ]\n\n\nMake migrations:\n\n.. code:: shell\n\n python manage.py migrate\n\n\nAdd ``likes.api.urls`` to your project urlpatterns:\n\n.. code:: python\n\n urlpatterns = [\n ...\n path('api/v1/', include('likes.api.urls')),\n ...\n ]\n\n\nAvailable settings\n==================\n\nAdd the models that you want to like to LIKES_MODELS in your settings file:\n\n.. code:: python\n\n LIKES_MODELS = {\n \"app.Model\": {\n 'serializer': 'app.api.serializer.YourModelSerializer'\n },\n }\n\n\nYou can set any pagination class for ListAPIView:\n\n.. code:: python\n \n LIKES_REST_PAGINATION_CLASS = 'core.api.pagination.MyResponsePagination'\n\n\nUsage\n=====\n\nAPI\n---\n\nBase endpoints\n**************\n\n1. ``/api/v1/likes/list/`` - List API View to return all likes for authenticated user.\n \n You can set ``serializer`` for each model in ``LIKES_MODELS`` setting to use it for content object serialization, otherwise, you will get an id of content object. \n\n For example:\n\n .. code:: python\n\n LIKE_MODELS = {\n \"article.Article\": {\n 'serializer': 'article.api.serializers.ArticleSerializer'\n },\n }\n\n\n Use ``GET`` parameter ``search`` to filter by a content type's model:\n `/api/v1/likes/list/?search=article`\n\n2. ``/api/v1/likes/count/`` - API View to return count of likes for authenticated user.\n\n3. ``/api/v1/likes/is/`` - API View to check is given elements are liked by authenticated user. As result, you will get a list of ``ids``. \n\n Possible payload:\n\n .. code:: json\n\n {\n \"content_type\": 1,\n \"ids\": [1,2,3]\n }\n \n\n Possible result:\n\n .. code:: json\n\n {\n \"ids\": [1,3]\n }\n \n\n4. ``/api/v1/likes/toggle/`` - API View to like-unlike a given object by authenticated user. \n \n Possible payload:\n\n .. code:: json\n\n {\n \"content_type\": 1,\n \"id\": 1\n }\n \n\n Possible result:\n\n .. code:: json\n\n {\n \"is_liked\": true\n }\n\n\nFilters\n-------\n\nlikes_count\n***********\n\nReturns a count of likes for a given object:\n\n.. code:: django\n\n {{ object|likes_count }}\n\n\nTemplate Tags\n-------------\n\nwho_liked\n*********\n\nReturns a queryset of users, who liked a given object:\n\n.. code:: django\n\n {% who_liked object as fans %}\n\n {% for user in fans %}\n