Enable settings for each user
Project description
Django User Settings
Installation
Install using pip
:
pip install django-user-settings
Requirements
django-user-settings requires these:
- django
- psycopg2
Example
Put user_settings
to INSTALLED_APPS
in settings.py
like this:
INSTALLED_APPS= (
...
'user_settings',
)
**Optional:
If you don't use your User model, django-user-settings will use default django User model.
from django.contrib.auth.models import User
Otherwise, you will need to add your User model to AUTH_USER_MODEL
in settings.py
:
AUTH_USER_MODEL = 'myapp.MyUser'
Now, you are ready to use django-user-settings, start with importing:
from user_settings.utils import get_user_setting, set_user_setting
get_user_setting(key, default_value=None, **kwargs)
Return user's setting in Python's dictionary
Arguments
key
: setting's name
default_value
: if django-user-settings cannot find suitable settings, this will be set to value of this key
**kwargs
:
'request': django's request
'uid': PK of user you want to get setting
If you pass both request
and uid
, django-user-settings will get settings of user with pk=uid
.
If you pass only request
, django-user-settings will get settings of current authenticated user.
If you pass uid
= None, django-user-settings will get settings with no specific user.
set_user_setting(key, value, **kwargs)
Arguments
key
: setting's name
value
: setting's value
**kwargs
:
'request': django's request, we will use this to get current authenticated user.
'uid': ID of user whose settings will be saved.
If you pass both request
and uid
, django-user-settings will save settings for user with pk=uid
.
If you pass only request
, django-user-settings will save settings for current authenticated user.
If you pass uid
= None, django-user-settings will save settings with no specific user.
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
Hashes for django-user-settings-0.0.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26e785910d977df72e4bb9af3786c66b4cd99694bd6d65c2c373bbb24a2130c1 |
|
MD5 | c6f91bdbb36ceb8bc8185a1745a7dc2d |
|
BLAKE2b-256 | 73306930758fefb9fc62993e226c6fed7c37b59012cd27d07bbcb6c71b684413 |
Hashes for django_user_settings-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12d72976cab86722a25c0121cdb62f2eee59825671dd4b1bc456790be32f35b6 |
|
MD5 | b64c9441a0dd5bc3243ca54090d84aec |
|
BLAKE2b-256 | 8ba1ddd12d705308a972f8566d2fe40928eaacb3a0bef7fc750fabfe025f61f5 |