🤠provides customization of AnonymousUser in Django
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
custom_anonymous
example
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
LICENSE
MANIFEST.in
README.markdown
requirements-dev.txt
requirements.txt
runtests.py
setup.py
tox.ini

README.markdown

django-custom-anonymous

Build Status

Library provides customization of AnonymousUser.

Works with Python >= 2.6, >= 3.2, Django >= 1.5, >= 2.0.

Installation

pip install django-custom-anonymous

Customization

Add to settings:

AUTH_ANONYMOUS_MODEL = 'your_app.module.CustomAnonymousUser'

Add to middlewares:

MIDDLEWARE = (
...
    'custom_anonymous.middleware.AuthenticationMiddleware',
...
)

Create your own anonymous (for example):

from django.contrib.auth.models import AnonymousUser as DjangoAnonymousUser
...
class CustomAnonymousUser(DjangoAnonymousUser):
    ip = None

    def __init__(self, request):
        self.ip = request.META.get('REMOTE_ADDR')
        super(AnonymousUser, self).__init__()