django-ok-likes 
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.
Installation
Install with pip:
pip install django-ok-likes
Update INSTALLED_APPS:
INSTALLED_APPS = [
...
'likes',
'rest_framework',
...
]
Make migrations:
python manage.py migrate
Add likes.api.urls to your project urlpatterns:
urlpatterns = [
...
path('api/v1/', include('likes.api.urls')),
...
]
Available settings
Add the models that you want to like to LIKES_MODELS in your settings file:
LIKES_MODELS = {
"app.Model": {
'serializer': 'app.api.serializer.YourModelSerializer'
},
}
You can set any pagination class for ListAPIView:
LIKES_REST_PAGINATION_CLASS = 'core.api.pagination.MyResponsePagination'
Usage
API
Base endpoints
/api/v1/likes/list/ - List API View to return all likes for authenticated user.
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.
For example:
LIKE_MODELS = { "article.Article": { 'serializer': 'article.api.serializers.ArticleSerializer' }, }Use GET parameter search to filter by a content type’s model: /api/v1/likes/list/?search=article
/api/v1/likes/count/ - API View to return count of likes for authenticated user.
/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.
Possible payload:
{ "type": 'app_label.model', # '.'.join(object_ct.natural_key()) "ids": [1,2,3] }Possible result:
{ "ids": [1,3] }/api/v1/likes/toggle/ - API View to like-unlike a given object by authenticated user.
Possible payload:
{ "type": 'app_label.model', # '.'.join(object_ct.natural_key()) "id": 1 }Possible result:
{ "is_liked": true }
Filters
likes_count
Returns a count of likes for a given object:
{{ object|likes_count }}
Jinja global functions
get_likes_count
The same as the likes_count filter.
Usage:
{{ get_likes_count(object) }}
get_who_liked
The same as the who_liked tag.
Usage:
{{ get_who_liked(object) }}
get_likes
The same as the likes tag.
Usage:
{{ get_likes(request.user) }}
get_is_liked
The same as the is_liked tag.
Usage:
{{ get_is_liked(object, request.user) }}
Signals
likes.signals.object_liked
A signal, which sents immediately after the object was liked and provides the single kwarg of created Like instance.
likes.signals.object_unliked
A signal, which sents immediately after the object was unliked and provides the single kwarg of an object.
Metadata
Release files for django-ok-likes 0.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-ok-likes-0.7.4.tar.gz | 14.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_ok_likes-0.7.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.0 kB
Release files / django-ok-likes-0.7.4.tar.gz
| Download URL | django-ok-likes-0.7.4.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b5d4305823b4b238a2441df5a5971dd4222092970d289b20114296689d4946c
|
|
BLAKE2b-256 checksum How to use checksums |
e93c9ebd9c26bec8162f367738383f8a2ec18120e45210d1f215246b2059cdf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
|
Release files / django_ok_likes-0.7.4-py3-none-any.whl
| Download URL | django_ok_likes-0.7.4-py3-none-any.whl |
|---|---|
| Size | 20.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fc6236aba31b8454c017151809334f26be54d575a151907d00e8cd701ca249b
|
|
BLAKE2b-256 checksum How to use checksums |
27cf6fa9190df1d0636eb96b0f7ca2b185c6f7b42e055a4d51e79fe83ae79545
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
|
Security for django-ok-likes 0.7.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.