django-rating-system


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

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

1. Install using pip

   .. code:: shell

      python -m pip install django-rating-system

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

   .. code:: shell

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

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

1. Add ``rating.apps.RatingConfig`` 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
          'rating.apps.RatingConfig',
      ]

      ...

      MEDIA_URL = '/media/'
      MEDIA_ROOT = BASE_DIR / 'media'

2. Add ``path('rating/', include('rating.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('rating/', include('rating.urls')),
      ]

      urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

3. Connect ``ratings`` to target model. In ``models.py`` add the field
   ``ratings`` as a GenericRelation field to the required model.

   **NOTE:** Please note that the field name must be ``ratings`` **NOT**
   ``rating``.

   .. code:: python

      # models.py

      from django.db import models
      from django.contrib.contenttypes.fields import GenericRelation
      from rating.models import Rating

      class Article(models.Model):
          title = models.CharField(max_length=20)
          content = models.TextField()
          # the field name should be ratings
          ratings = GenericRelation(Rating)

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

2. Add the following template tag to load stylesheet.

   .. code:: html

      {% render_rating_import %}

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

   .. code:: html

      {% render_rating request obj settings_slug='default-config' %}  {# Render all the ratings 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_rating request obj=article settings_slug='default-config' %}

4. Add the following template tag to show rating information.

   .. code:: html

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

   use ``custom_template`` if you want to render your own template.

   .. code:: html

      {% render_rating_info request=request obj=article settings_slug='default-config' custom_template='my_custom_rating_info.html' %}

5. Add ``render_rating_script`` tag at the end of the last
   ``render_rating`` tag.

   .. code:: html

      {% render_rating_import %}

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

      {% render_rating request=request obj=article settings_slug='like-config' %}
      {% render_rating_info request=request obj=article settings_slug='like-config' custom_template='rating/rating_info.html' %}

      {% render_rating_script %}

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mahyar-amiri/django-rating-system",
    "name": "django-rating-system",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django rating rating-system django-rating ratings ratings-system django-ratings ajax",
    "author": "Mahyar Amiri",
    "author_email": "mmaahhyyaarr@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/81/7d/ed8a93408d109b4dafc7e19377be1e0c817c42014a8252b8977ad21b8180/django-rating-system-1.1.1.tar.gz",
    "platform": null,
    "description": "Django Rating System\n====================\n\nInstallation\n------------\n\n1. Install using pip\n\n   .. code:: shell\n\n      python -m pip install django-rating-system\n\n   or Clone the repository then copy ``rating`` folder and paste in\n   project folder.\n\n   .. code:: shell\n\n      git clone https://github.com/mahyar-amiri/django-rating-system.git\n\nConfiguration\n-------------\n\n1. Add ``rating.apps.RatingConfig`` 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          'rating.apps.RatingConfig',\n      ]\n\n      ...\n\n      MEDIA_URL = '/media/'\n      MEDIA_ROOT = BASE_DIR / 'media'\n\n2. Add ``path('rating/', include('rating.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('rating/', include('rating.urls')),\n      ]\n\n      urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n\n3. Connect ``ratings`` to target model. In ``models.py`` add the field\n   ``ratings`` as a GenericRelation field to the required model.\n\n   **NOTE:** Please note that the field name must be ``ratings`` **NOT**\n   ``rating``.\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 rating.models import Rating\n\n      class Article(models.Model):\n          title = models.CharField(max_length=20)\n          content = models.TextField()\n          # the field name should be ratings\n          ratings = GenericRelation(Rating)\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 rating_tags %}\n\n2. Add the following template tag to load stylesheet.\n\n   .. code:: html\n\n      {% render_rating_import %}\n\n3. Add the following template tags where you want to render ratings.\n\n   .. code:: html\n\n      {% render_rating request obj settings_slug='default-config' %}  {# Render all the ratings 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_rating request obj=article settings_slug='default-config' %}\n\n4. Add the following template tag to show rating information.\n\n   .. code:: html\n\n      {% render_rating_info request=request obj=article settings_slug='default-config' %}\n\n   use ``custom_template`` if you want to render your own template.\n\n   .. code:: html\n\n      {% render_rating_info request=request obj=article settings_slug='default-config' custom_template='my_custom_rating_info.html' %}\n\n5. Add ``render_rating_script`` tag at the end of the last\n   ``render_rating`` tag.\n\n   .. code:: html\n\n      {% render_rating_import %}\n\n      {% render_rating request=request obj=article settings_slug='default-config' %}\n      {% render_rating_info request=request obj=article settings_slug='default-config' %}\n\n      {% render_rating request=request obj=article settings_slug='like-config' %}\n      {% render_rating_info request=request obj=article settings_slug='like-config' custom_template='rating/rating_info.html' %}\n\n      {% render_rating_script %}\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django rating System, It can be associated with any given model.",
    "version": "1.1.1",
    "split_keywords": [
        "django",
        "rating",
        "rating-system",
        "django-rating",
        "ratings",
        "ratings-system",
        "django-ratings",
        "ajax"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1592d92f5e61528fc4a4d21cb4ff37caa7804eb5ec640fa701adc8bb780e403d",
                "md5": "412a9db9d6836672d914db4bec598ce8",
                "sha256": "15dba151428a98e21dd8484db2250c91c8cbc17ce51e5d7bc23f887a7e5df4d5"
            },
            "downloads": -1,
            "filename": "django_rating_system-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "412a9db9d6836672d914db4bec598ce8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17863,
            "upload_time": "2023-04-15T11:45:54",
            "upload_time_iso_8601": "2023-04-15T11:45:54.709346Z",
            "url": "https://files.pythonhosted.org/packages/15/92/d92f5e61528fc4a4d21cb4ff37caa7804eb5ec640fa701adc8bb780e403d/django_rating_system-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "817ded8a93408d109b4dafc7e19377be1e0c817c42014a8252b8977ad21b8180",
                "md5": "ec7e31fc96d01b81c93b26a8f33b8fc3",
                "sha256": "cce9e1b86c9de6d47a68017b7f0fd0d1c579a1597422a1a44debdb62920d5922"
            },
            "downloads": -1,
            "filename": "django-rating-system-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ec7e31fc96d01b81c93b26a8f33b8fc3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13802,
            "upload_time": "2023-04-15T11:45:56",
            "upload_time_iso_8601": "2023-04-15T11:45:56.656217Z",
            "url": "https://files.pythonhosted.org/packages/81/7d/ed8a93408d109b4dafc7e19377be1e0c817c42014a8252b8977ad21b8180/django-rating-system-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-15 11:45:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "mahyar-amiri",
    "github_project": "django-rating-system",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-rating-system"
}
        
Elapsed time: 0.06525s