# 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.
Release files for django-user-settings 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-user-settings-0.0.12.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_user_settings-0.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.0 kB
Release files / django-user-settings-0.0.12.tar.gz
| Download URL | django-user-settings-0.0.12.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3c6078f24cd76697448aa80944518bb0cc0084398965ca305b16ae7778ee2dd
|
|
BLAKE2b-256 checksum How to use checksums |
e608b1eb7f759c714b8b076aeecde5f8796cc255dc7fc002cad2e743c4e43cfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.7
|
Release files / django_user_settings-0.0.12-py3-none-any.whl
| Download URL | django_user_settings-0.0.12-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c3b8fa1dcc254f186a83830275d2ed7cd61bc438f3a6760d5eaaf24aac4e40e
|
|
BLAKE2b-256 checksum How to use checksums |
83115ee71698368d23f413d25bce3c4b4cf4824897d614f25b727facade30faf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.7
|