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.8.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94208739595759a7f1b1426ae69570a0def5d5a996663dbf48702f2d355d755e |
|
MD5 | 10b7120ee0da77ac8272e34ca2461a4a |
|
BLAKE2b-256 | cea757c9529592ac1667f3017be7ffbbe3e41f950c1c127619fce1f7e4636143 |
Close
Hashes for django_user_settings-0.0.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc47c018387bf35da0cb934e5fc73d262d37cefb4b1e4fac79a23df3c23aa6d6 |
|
MD5 | 0012092206514415f74088e97e7ea6ad |
|
BLAKE2b-256 | e887700edc30569aa119b5b31949f5405771e9143a012f969b49ba2c9ff7a74e |