Enable settings for each user
Project description
# Django User Settings
## Installation
Install using `pip`:
```bash
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:
```python
INSTALLED_APPS= (
...
'user_settings',
)
```
**Optional:
If you don't use your User model, django-user-settings will use default django User model.
```python
from django.contrib.auth.models import User
```
Otherwise, you will need to add your User model to `AUTH_USER_MODEL` in `settings.py`:
```python
AUTH_USER_MODEL = 'myapp.MyUser'
```
Now, you are ready to use **django-user-settings**, start with importing:
```python
from user_settings.utils import get_user_setting, set_user_setting
```
```python
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.
```python
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.
## Installation
Install using `pip`:
```bash
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:
```python
INSTALLED_APPS= (
...
'user_settings',
)
```
**Optional:
If you don't use your User model, django-user-settings will use default django User model.
```python
from django.contrib.auth.models import User
```
Otherwise, you will need to add your User model to `AUTH_USER_MODEL` in `settings.py`:
```python
AUTH_USER_MODEL = 'myapp.MyUser'
```
Now, you are ready to use **django-user-settings**, start with importing:
```python
from user_settings.utils import get_user_setting, set_user_setting
```
```python
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.
```python
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
Close
Hashes for django-user-settings-0.0.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 838fa171b84aff787900f0d6b8b5499834654065dbfcf3e5e69577b322a27ffd |
|
MD5 | 9c51c93bf8b28044ae9616ee2b995135 |
|
BLAKE2b-256 | d24f0fce8d43cea01cd86a68986fe5021c448104135dc978a75da2ef83491fce |
Close
Hashes for django_user_settings-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75aaed5c47efdf21cc4a0ea9db694f211f55c985110a2cbca5af02a5e81cc2ee |
|
MD5 | 100e044bf8aaaca0ea11be712ae5fc85 |
|
BLAKE2b-256 | ae706d2c3819ed8cbe2bb666c3f0bd4f2a2230b5584d53ea04f48aa74e1902a5 |