Codebase list django-stronghold / aee9616
Updated README.md Paweł Adamczak authored 6 years ago GitHub committed 6 years ago
1 changed file(s) with 12 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
00 [![Build Status](https://travis-ci.org/mgrouchy/django-stronghold.svg?branch=master)](https://travis-ci.org/mgrouchy/django-stronghold)
11
2 #Stronghold
2 # Stronghold
33
44 Get inside your stronghold and make all your Django views default login_required
55
77
88 WARNING: still in development, so some of the DEFAULTS and such will be changing without notice.
99
10 ##Installation
10 ## Installation
1111
1212 Install via pip.
1313
3535
3636 ```
3737
38 ##Usage
38 ## Usage
3939
4040 If you followed the installation instructions now all your views are defaulting to require a login.
4141 To make a view public again you can use the public decorator provided in `stronghold.decorators` like so:
4242
43 ###For function based views
43 ### For function based views
4444 ```python
4545 from stronghold.decorators import public
4646
5252
5353 ```
5454
55 ###for class based views (decorator)
55 ### For class based views (decorator)
5656
5757 ```python
5858 from django.utils.decorators import method_decorator
6969 return super(SomeView, self).dispatch(*args, **kwargs)
7070 ```
7171
72 ###for class based views (mixin)
72 ### For class based views (mixin)
7373
7474 ```python
7575 from stronghold.views import StrongholdPublicMixin
7979 pass
8080 ```
8181
82 ##Configuration (optional)
82 ## Configuration (optional)
8383
8484
85 ###STRONGHOLD_DEFAULTS
85 ### STRONGHOLD_DEFAULTS
8686
8787 Use Strongholds defaults in addition to your own settings.
8888
9797 will be made public without using the `@public` decorator.
9898
9999
100 ###STRONGHOLD_PUBLIC_URLS
100 ### STRONGHOLD_PUBLIC_URLS
101101
102102 **Default**:
103103 ```python
118118
119119 > Note: Public URL regexes are matched against [HttpRequest.path_info](https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.path_info).
120120
121 ###STRONGHOLD_PUBLIC_NAMED_URLS
121 ### STRONGHOLD_PUBLIC_NAMED_URLS
122122 You can add a tuple of url names in your settings file with the
123123 `STRONGHOLD_PUBLIC_NAMED_URLS` setting. Names in this setting will be reversed using
124124 `django.core.urlresolvers.reverse` and any url matching the output of the reverse
132132 If STRONGHOLD_DEFAULTS is True additionally we search for `django.contrib.auth`
133133 if it exists, we add the login and logout view names to `STRONGHOLD_PUBLIC_NAMED_URLS`
134134
135 ###STRONGHOLD_USER_TEST_FUNC
135 ### STRONGHOLD_USER_TEST_FUNC
136136 Optionally, set STRONGHOLD_USER_TEST_FUNC to a callable to limit access to users
137137 that pass a custom test. The callback receives a `User` object and should
138138 return `True` if the user is authorized. This is equivalent to decorating a
161161 * Django 1.9.x
162162 * Django 1.10.x
163163
164 ##Contribute
164 ## Contribute
165165
166166 See CONTRIBUTING.md