File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -8,3 +8,30 @@ This includes:
88* Abstract UserPref Class
99* Admin interface
1010* Templates for an userspecific settings page
11+
12+
13+ Basic usage
14+ ===========
15+
16+ Just define a abstract model that can be used in the applications.
17+ In you app you should define something like:
18+
19+ .. code :: python
20+
21+ from userpref.models import Userpref
22+
23+ class MyappSettings (Userpref ):
24+ special_setting = models.BooleanField(default = False , verbose_name = ' Make me a superhero' )
25+ another_field = models.CharField(max_length = 100 , default = " <unset>" )
26+
27+ class Meta :
28+ verbose_name = " My Custom Setting for app Myapp"
29+
30+
31+ In your application or template you can access the settings over the users attributes
32+
33+ .. code :: html
34+
35+ {% if request.user.myappsettings.special_settings %}
36+ You are special man!
37+ {% endif %}
Original file line number Diff line number Diff line change @@ -16,11 +16,22 @@ Basic usage
1616Just define a abstract model that can be used in the applications.
1717In you app you should define something like:
1818
19+ .. code :: python
20+
1921 from userpref.models import Userpref
2022
2123 class MyappSettings (Userpref ):
2224 special_setting = models.BooleanField(default = False , verbose_name = ' Make me a superhero' )
2325 another_field = models.CharField(max_length = 100 , default = " <unset>" )
2426
2527 class Meta :
26- verbose_name = "My Custom Setting for app Myapp"
28+ verbose_name = " My Custom Setting for app Myapp"
29+
30+
31+ In your application or template you can access the settings over the users attributes
32+
33+ .. code :: html
34+
35+ {% if request.user.myappsettings.special_settings %}
36+ You are special man!
37+ {% endif %}
Original file line number Diff line number Diff line change 1313 # Versions should comply with PEP440. For a discussion on single-sourcing
1414 # the version across setup.py and the project code, see
1515 # https://packaging.python.org/en/latest/single_source_version.html
16- version = '0.1.0a3 ' ,
16+ version = '0.1.0a5 ' ,
1717
1818 description = 'Django user preferences' ,
1919 long_description = long_description ,
You can’t perform that action at this time.
0 commit comments