https://github.com/bugov/django-custom-anonymous
š¤ provides customization of AnonymousUser in Django
https://github.com/bugov/django-custom-anonymous
customization django python user
Last synced: 3 months ago
JSON representation
š¤ provides customization of AnonymousUser in Django
- Host: GitHub
- URL: https://github.com/bugov/django-custom-anonymous
- Owner: bugov
- License: bsd-3-clause
- Created: 2015-04-29T18:46:49.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-07-19T12:22:43.000Z (almost 7 years ago)
- Last Synced: 2025-12-11T17:31:51.644Z (6 months ago)
- Topics: customization, django, python, user
- Language: Python
- Homepage:
- Size: 22.5 KB
- Stars: 17
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
django-custom-anonymous
=======================
.. figure:: https://travis-ci.org/bugov/django-custom-anonymous.svg?branch=master
Library provides customization of AnonymousUser.
Works with Python >= 2.6, >= 3.2, Django >= 1.5, >= 2.0.
Installation
------------
.. code:: bash
pip install django-custom-anonymous
Customization
-------------
Add to `settings`:
.. code:: python
AUTH_ANONYMOUS_MODEL = 'your_app.module.CustomAnonymousUser'
Add to middlewares:
.. code:: python
MIDDLEWARE = (
...
'custom_anonymous.middleware.AuthenticationMiddleware',
...
)
Create your own anonymous (for example):
.. code:: python
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__()