django account helper utils for `django.contrib.auth`
Project description
django account helper utils for django.contrib.auth
Requirement
Django
Install
pip install django_acocunt_helper
Config
check your settings.py, make sure django.contrib.auth in INSTALLED_APPS.
add account_helper.middleware.CurrentUserMiddleware
config finish.
How to use
set current user as default value
update your model like this:
before
owner = models.ForeignKey(settings.AUTH_USER_MODEL)
after
from account_helper.middleware import get_current_user
# ... fields definition...
owner = models.ForeignKey(settings.AUTH_USER_MODEL, default=get_current_user)
set current user id as default value
update your model like this:
before
owner = models.IntegerField('user id')
after
from account_helper.middleware import get_current_user_id
# ... fields definition...
owner = models.IntegerField('user id',default=get_current_user_id)
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
Close
Hashes for django-account-helper-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14849ac9daf7698dacadc49ce6e12bf05b67b2f2748c544ceb59ccded6c8139c |
|
MD5 | 2bb31deeb4cacb737345f2d141dd0265 |
|
BLAKE2b-256 | 5538d9179a157f17eaaa1d3bcb33ca64039b968155489717721ddaa06a8a5267 |