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.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c05379094fd767e33cf52e71416d4c023767837f6311fdf85dedf199afbb61b |
|
MD5 | 46b6124fa09377e6949116b5315d31dd |
|
BLAKE2b-256 | 31aa67bc57a7d73802a819e1180630275300cfce880baaa54157643d6fae2008 |
Hashes for django_user_settings-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8d3329fd0880f5f6dbc7c3d0777141f95b1b233a4748645cc1b58551ce1d226 |
|
MD5 | 666a883c9dac16c832f14258ce3b6617 |
|
BLAKE2b-256 | 8f9dd67de1f2a054cb7b3eebd717078e66a88e735e4cd3c8257469cef9e56fac |