Usage¶
Views & Decorators¶
django-latch exposes the following views:
-
latch.views.
pair
(request, template_name="latch_pair.html")¶ Process the pair form. If the user is alredy paired, redirects to the status view and shows a message using Django Message Framework.
View Name:
latch_pair
-
latch.views.
unpair
(request, template_name="latch_unpair.html")¶ Process the unpair form. If the user is not paired, redirects to the status view and shows a message using Django Message Framework.
View Name:
latch_unpair
-
latch.views.
status
(request, template_name="latch_status.html")¶ Show status about installation. We load two variables in this view:
accountid
Latch API account ID of the current user, if the account is paired.account_status
Indicating if the user can login, valueon
, or not, valueoff
.
Also note that retrieving status using the API will count as an login attempt, and the users can receive notifications on their devices.
View Name:
latch_status
Also, it expose a decorator
-
latch.views.
latch_is_configured
(view)¶ If Latch is installed but not configured, decorated views will redirect to
status
instead.
Templates¶
Like django.contrib.auth we extend Django Admin templates. You can override the following templates:
latch
└── templates
├── latch_pair.html
├── latch_status.html
└── latch_unpair.html
Loggers¶
We log failed API connections using logger.exception
.
When LATCH_BYPASS_WHEN_UNREACHABLE
we register each bypassed login with info
level.