Django + Fighting Spam Made Easy
Python Makefile HTML
Latest commit 924dbe7 Jun 16, 2016 @pydanny committed on GitHub Merge pull request #10 from adamchainz/
Convert readthedocs links for their .org -> .io migration for hosted projects
Failed to load latest commit information.
docs Fixing the docs Oct 28, 2015
spam Fixed indentation. Close issue #8 Oct 28, 2015
test_app Fix all flake8 'E302 expected 2 blank lines, found 1' errors. Sep 2, 2015
tests Refactored even more code into utils Aug 12, 2015
.coveragerc Update coveragerc Oct 28, 2015
.editorconfig Remove known_first_party since this is a third-party app. Aug 16, 2015
.gitignore Factor b16_slug_to_arguments into it's own function Aug 10, 2015
.travis.yml Added Python 3.5 support Nov 21, 2015
AUTHORS.rst first commit Jul 29, 2015
CONTRIBUTING.rst first commit Jul 29, 2015
HISTORY.rst Added Python 3.5 support Nov 21, 2015
LICENSE first commit Jul 29, 2015 first commit Jul 29, 2015
README.rst Convert readthedocs links for their .org -> .io migration for hosted … Jun 15, 2016
requirements.txt Update requirements Jul 29, 2015 A bit shakey, but we can now test views (#4) Aug 3, 2015
setup.cfg Nuking coveralls per #7 Aug 22, 2015
tox.ini Added py35 to tox Nov 16, 2015


Work in Progress: dj-spam

Django + Flagging Spam Made Easy


The full documentation is at


  • For Django 1.8+
  • For Python 2.7/3.3+
  • Direct foreign key from the model to the spam report. Avoiding content types and using explicit foreign keys makes for less kludgy databases.
  • Powered by conventions used all over Django:
    • Have the appropriate __str__() or __unicode__() method on your models.
    • Flaggable models should have get_absolute_url() methods.


Install dj-spam:

pip install dj-spam

Configure it into your project:

INSTALLED_APPS += ['spam', ]
url(r'^spam/', include('spam.urls', namespace='spam')),

For any model you want to flag:

from spam import Spammable

class MyModel(Spammable, models.Model):
    # Define your model here. Spammable attaches
    #   the spam_flag field to your model as a ManyToManyField.

    def get_absolute_url(self):
        # Not required, but it allows dj-spam to link back to the offending
        # content in the report spam view.
        return 'absolute link to model detail view'

Run Migrations

./manage migrate

Then, in the model's related view:

from spam import SpammableMixin

class MyModelDetailView(SpammableMixin, DetailView):
    class = MyModel

This empowers you with the view method spam_report_url which you can use to define the URL to the reporting form:

<a href="{{ view.spam_report_url }}">Report Spam</a>


dj-spam comes with a simple admin view.

emailing managers

dj-spam emails settings.MANAGERS every time something is flagged. If you don't set settings.MANAGERS, it will email settings.ADMINS.

Running tests locally

coverage run ./ test