Django Reaction System
Installation
Install using pip
python -m pip install django-reaction-systemor Clone the repository then copy reaction folder and paste in project folder.
git clone https://github.com/mahyar-amiri/django-reaction-system.git
Configuration
Add reaction.apps.ReactionConfig to installed_apps after django.contrib.auth in the settings.py file. Add MEDIA_URL and MEDIA_ROOT.
# setting.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # MY APPS 'reaction.apps.ReactionConfig', ] ... MEDIA_URL = '/media/' MEDIA_ROOT = BASE_DIR / 'media'Add path('reaction/', include('reaction.urls')), and media root to urlpatterns in the project urls.py file.
# urls.py from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('reaction/', include('reaction.urls')), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)Connect reaction to target model. In models.py add the field reactions as a GenericRelation field to the required model.
NOTE: Please note that the field name must be reactions NOT reaction.
# models.py from django.db import models from django.contrib.contenttypes.fields import GenericRelation from reaction.models import Reaction class Article(models.Model): title = models.CharField(max_length=20) content = models.TextField() # the field name should be reactions reactions = GenericRelation(Reaction)Do migrations
python manage.py migrate
Usage
In the template (e.g. post_detail.html) add the following template tags where obj is the instance of post model.
{% load reaction_tags %}Add the following template tag to load stylesheet.
{% render_reaction_import %}Add the following template tags where you want to render reactions.
{% render_reaction request obj settings_slug='default-config' %} {# Render all the reactions belong to the passed object "obj" #}if your context_object_name is not obj (e.g. article) replace obj with context_object_name.
{% render_reaction request obj=article settings_slug='default-config' %}Add render_reaction_script tag at the end of the last render_reaction tag.
{% render_reaction_import %} {% render_reaction request=request obj=article settings_slug='default-config' %} {% render_reaction request=request obj=article settings_slug='second-config' %} {% render_reaction_script %}
Metadata
Release files for django-reaction-system 1.1.1
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 | Actions |
|---|---|---|---|---|
| django-reaction-system-1.1.1.tar.gz | 12.8 kB | Without provenance | Details for django-reaction-system-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_reaction_system-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for django_reaction_system-1.1.1-py3-none-any.whl |
Total release size: 29.3 kB
Release files / django-reaction-system-1.1.1.tar.gz
| Download URL | django-reaction-system-1.1.1.tar.gz |
|---|---|
| Size | 12.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b12d2f7c2477d256ee7f29b4c129a56c6e6b1fa547b5728088f3354d84630911
|
|
BLAKE2b-256 checksum How to use checksums |
fc5f69af44174908928fd1da475d5faa4c31e9c367a6500cd9e0e47ae0f6c98d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Release files / django_reaction_system-1.1.1-py3-none-any.whl
| Download URL | django_reaction_system-1.1.1-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a95b48add9394ef5fb78d70644f1a637a383ba1fa8a998190bd3dfc8d5777da
|
|
BLAKE2b-256 checksum How to use checksums |
9dd4780254bbab9ba4c04c2cf4138267f1adf5d988521f57f24b35a50e909f99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.3
|
Security for django-reaction-system 1.1.1
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.