Skip to main content

A pluggable django application that adds the ability for users to flag(or report) your models

Project description

Test Coverage Latest PyPi version python django docs licence

A pluggable django application that adds the ability for users to flag(report or moderate) your models.

flagging-process

For complete documentation you may visit Read the Doc. or see the docs directory.

Installation

Install using pip

$ pip install django-flag-app

If you want, you may install it from the source, grab the source code and install it.

$ git clone git://github.com/abhiabhi94/django-flag-app.git
$ cd django-flag-app
$ pip install .

Usage

Add app

To enable django_flag_app in your project you need to add it to INSTALLED_APPS in your projects settings.py file:

INSTALLED_APPS = (
    ...
    'flag',
    ...
)

Add URL

In your root urls.py:

urlpatterns = patterns(
        path('admin/', admin.site.urls),
        path('flag/', include('flag.urls')),
        ...
        path('api/', include('flag.api.urls')),  # only required for API Framework
        ...
    )

Migrate

Run the migrations to add the new models to your database:

python manage.py migrate flag

Connect the flag model with the target model

In models.py add the field flags as a GenericRelation field to the required model.

E.g. for a Post model, you may add the field as shown below:

from django.contrib.contenttypes.fields import GenericRelation

from flag.models import Flag


class Post(models.Model):
    user = models.ForeignKey(User)
    title = models.CharField(max_length=200)
    body = models.TextField()
    # the field name should be flags
    flags = GenericRelation(Flag)

Use template tag

If you want to use web API, this step is not required. See further instructions at Web API.

render_flag_form tag requires 3 required positional arguments:

  1. Instance of the targeted model.

  2. User object.

  3. Request object

To render the flag form for a the instance post, place this inside your detail view, perhaps in some template of the sort postdetail.html.

{% render_flag_form post user request %}

Contributing

Please see the instructions at Contributing.rst.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_flag_app-2.0.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_flag_app-2.0.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file django_flag_app-2.0.0.tar.gz.

File metadata

  • Download URL: django_flag_app-2.0.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for django_flag_app-2.0.0.tar.gz
Algorithm Hash digest
SHA256 29898fa7b9c3aea66f8b4c98f92c1b6063784d9e60fca8a3d71fddcb6f2b13e7
MD5 cdae8122940b83d2d638e814b120402a
BLAKE2b-256 d47967e74db44c4fa66a31a0cfd224894a262ecea3ee91c3bc56117d6f2388f5

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_flag_app-2.0.0.tar.gz:

Publisher: release.yml on abhiabhi94/django-flag-app

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_flag_app-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_flag_app-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3c364d699416d7a481b6b08badf3c6dd92d3b158575bb12b4a3da80f36ca440
MD5 5e1db665f49892b96c797e8782d68fe4
BLAKE2b-256 35e60e9db1f6a8c9a3286893a6f8f2098bc56e66afd6b372124a674480f14378

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_flag_app-2.0.0-py3-none-any.whl:

Publisher: release.yml on abhiabhi94/django-flag-app

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page