django-reaction-system


Namedjango-reaction-system JSON
Version 1.1.1 PyPI version JSON
download
home_pagehttps://github.com/mahyar-amiri/django-reaction-system
SummaryDjango reaction System, It can be associated with any given model.
upload_time2023-04-15 12:13:05
maintainer
docs_urlNone
authorMahyar Amiri
requires_python
licenseMIT
keywords django reaction reaction-system django-reaction reactions reactions-system django-reactions ajax
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Django Reaction System
======================

Installation
------------

1. Install using pip

   .. code:: shell

      python -m pip install django-reaction-system

   or Clone the repository then copy ``reaction`` folder and paste in
   project folder.

   .. code:: shell

      git clone https://github.com/mahyar-amiri/django-reaction-system.git

Configuration
-------------

1. Add ``reaction.apps.ReactionConfig`` to installed_apps after
   ``django.contrib.auth`` in the ``settings.py`` file. Add
   ``MEDIA_URL`` and ``MEDIA_ROOT``.

   .. code:: python

      # 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'

2. Add ``path('reaction/', include('reaction.urls')),`` and media root to
   urlpatterns in the project ``urls.py`` file.

   .. code:: python

      # 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)

3. 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``.

   .. code:: python

      # 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)

4. Do migrations

   .. code:: shell

      python manage.py migrate

Usage
-----

1. In the template (e.g. post_detail.html) add the following template
   tags where obj is the instance of post model.

   .. code:: html

      {% load reaction_tags %}

2. Add the following template tag to load stylesheet.

   .. code:: html

      {% render_reaction_import %}

3. Add the following template tags where you want to render reactions.

   .. code:: html

      {% 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.

   .. code:: html

      {% render_reaction request obj=article settings_slug='default-config' %}

4. Add ``render_reaction_script`` tag at the end of the last
   ``render_reaction`` tag.

   .. code:: html

      {% 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 %}

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mahyar-amiri/django-reaction-system",
    "name": "django-reaction-system",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django reaction reaction-system django-reaction reactions reactions-system django-reactions ajax",
    "author": "Mahyar Amiri",
    "author_email": "mmaahhyyaarr@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fc/5f/69af44174908928fd1da475d5faa4c31e9c367a6500cd9e0e47ae0f6c98d/django-reaction-system-1.1.1.tar.gz",
    "platform": null,
    "description": "Django Reaction System\n======================\n\nInstallation\n------------\n\n1. Install using pip\n\n   .. code:: shell\n\n      python -m pip install django-reaction-system\n\n   or Clone the repository then copy ``reaction`` folder and paste in\n   project folder.\n\n   .. code:: shell\n\n      git clone https://github.com/mahyar-amiri/django-reaction-system.git\n\nConfiguration\n-------------\n\n1. Add ``reaction.apps.ReactionConfig`` to installed_apps after\n   ``django.contrib.auth`` in the ``settings.py`` file. Add\n   ``MEDIA_URL`` and ``MEDIA_ROOT``.\n\n   .. code:: python\n\n      # setting.py\n\n      INSTALLED_APPS = [\n          'django.contrib.admin',\n          'django.contrib.auth',\n          'django.contrib.contenttypes',\n          'django.contrib.sessions',\n          'django.contrib.messages',\n          'django.contrib.staticfiles',\n\n          # MY APPS\n          'reaction.apps.ReactionConfig',\n      ]\n\n      ...\n\n      MEDIA_URL = '/media/'\n      MEDIA_ROOT = BASE_DIR / 'media'\n\n2. Add ``path('reaction/', include('reaction.urls')),`` and media root to\n   urlpatterns in the project ``urls.py`` file.\n\n   .. code:: python\n\n      # urls.py\n\n      from django.urls import path, include\n      from django.conf import settings\n      from django.conf.urls.static import static\n\n      urlpatterns = [\n           path('reaction/', include('reaction.urls')),\n      ]\n\n      urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n\n3. Connect ``reaction`` to target model. In ``models.py`` add the field\n   ``reactions`` as a GenericRelation field to the required model.\n\n   **NOTE:** Please note that the field name must be ``reactions`` **NOT**\n   ``reaction``.\n\n   .. code:: python\n\n      # models.py\n\n      from django.db import models\n      from django.contrib.contenttypes.fields import GenericRelation\n      from reaction.models import Reaction\n\n      class Article(models.Model):\n          title = models.CharField(max_length=20)\n          content = models.TextField()\n          # the field name should be reactions\n          reactions = GenericRelation(Reaction)\n\n4. Do migrations\n\n   .. code:: shell\n\n      python manage.py migrate\n\nUsage\n-----\n\n1. In the template (e.g. post_detail.html) add the following template\n   tags where obj is the instance of post model.\n\n   .. code:: html\n\n      {% load reaction_tags %}\n\n2. Add the following template tag to load stylesheet.\n\n   .. code:: html\n\n      {% render_reaction_import %}\n\n3. Add the following template tags where you want to render reactions.\n\n   .. code:: html\n\n      {% render_reaction request obj settings_slug='default-config' %}  {# Render all the reactions belong to the passed object \"obj\" #}\n\n   if your context_object_name is not ``obj`` (e.g. article) replace obj\n   with context_object_name.\n\n   .. code:: html\n\n      {% render_reaction request obj=article settings_slug='default-config' %}\n\n4. Add ``render_reaction_script`` tag at the end of the last\n   ``render_reaction`` tag.\n\n   .. code:: html\n\n      {% render_reaction_import %}\n\n      {% render_reaction request=request obj=article settings_slug='default-config' %}\n      {% render_reaction request=request obj=article settings_slug='second-config' %}\n\n      {% render_reaction_script %}\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django reaction System, It can be associated with any given model.",
    "version": "1.1.1",
    "split_keywords": [
        "django",
        "reaction",
        "reaction-system",
        "django-reaction",
        "reactions",
        "reactions-system",
        "django-reactions",
        "ajax"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9dd4780254bbab9ba4c04c2cf4138267f1adf5d988521f57f24b35a50e909f99",
                "md5": "05cbb53f0cf8ce7e0d67586598f30aa6",
                "sha256": "6a95b48add9394ef5fb78d70644f1a637a383ba1fa8a998190bd3dfc8d5777da"
            },
            "downloads": -1,
            "filename": "django_reaction_system-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "05cbb53f0cf8ce7e0d67586598f30aa6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 16585,
            "upload_time": "2023-04-15T12:13:04",
            "upload_time_iso_8601": "2023-04-15T12:13:04.364411Z",
            "url": "https://files.pythonhosted.org/packages/9d/d4/780254bbab9ba4c04c2cf4138267f1adf5d988521f57f24b35a50e909f99/django_reaction_system-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc5f69af44174908928fd1da475d5faa4c31e9c367a6500cd9e0e47ae0f6c98d",
                "md5": "6f7bfae85dca4b049139ebdad0019142",
                "sha256": "b12d2f7c2477d256ee7f29b4c129a56c6e6b1fa547b5728088f3354d84630911"
            },
            "downloads": -1,
            "filename": "django-reaction-system-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6f7bfae85dca4b049139ebdad0019142",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12757,
            "upload_time": "2023-04-15T12:13:05",
            "upload_time_iso_8601": "2023-04-15T12:13:05.988169Z",
            "url": "https://files.pythonhosted.org/packages/fc/5f/69af44174908928fd1da475d5faa4c31e9c367a6500cd9e0e47ae0f6c98d/django-reaction-system-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-15 12:13:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "mahyar-amiri",
    "github_project": "django-reaction-system",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-reaction-system"
}
        
Elapsed time: 1.69135s