Enable settings for each user
Project description
Django User Settings
Installation
Download django-user-settings-0.0.1 under:
/dist/django-user-settings-0.0.1.tar.gz
Install using pip:
pip install path/to/file/django-user-settings-0.0.1.tar.gz
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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9561e0822b56231bdcf288e63aa1d6690d18fbdcfcb6fa251768b54653e8359f |
|
MD5 | 78d10960c294460c4ea45ff41e4c2803 |
|
BLAKE2b-256 | f8c453ef78dce6dbf14e4fca61061c60ee0c59116ea182e2db6398db3af58163 |
Hashes for django_user_settings-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a7b449e1cd766be6aa0702335360f028e91a2fdbd4573618a5b3dd3d2fc461b |
|
MD5 | 21836339f855be3dc19a95f076d974b8 |
|
BLAKE2b-256 | d3ccc276658727a9478ee6eb029925bd78b68325f9e0e3105a8dfa46529bae74 |