A pluggable django application that adds the ability for users to flag(or report) your models
Project description
A pluggable django application that adds the ability for users to flag(report or moderate) your models.
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 run setup.py.
$ git clone git://github.com/abhiabhi94/django-flag-app.git
$ cd django-flag-app
$ python setup.py 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:
Instance of the targeted model.
User object.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-flag-app-1.3.0.tar.gz
.
File metadata
- Download URL: django-flag-app-1.3.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e722e6290dca1e79a0e6ee063f2d56f4294f3696ad950dd7a279499f74fbd4b0 |
|
MD5 | 1b598b5ff3cc8b536190def0ae11615f |
|
BLAKE2b-256 | 6a2d8e59ddc479b78dee2c753351e7120d2bc1238c2f05d20aa761d2703cb02e |
File details
Details for the file django_flag_app-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: django_flag_app-1.3.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f494d05b8044f602342517045348b50e923a85513e1f6114a92ba4470a83e5bb |
|
MD5 | 3b043b633b020c06a8db162f1994c2aa |
|
BLAKE2b-256 | a7fdb247985194bbf0d87f8910a0e52707d89a574c1d5d17f7c49310e8736aa1 |