Django Lookout¶
Install and Configure¶
Warning
If you’re using HPKP, Django Lookout must be set up on a different domain name.
Step 1: Install¶
pip install Django-Lookout
Step 2: Update INSTALLED_APPS
¶
Add the app to your project’s settings.py
:
INSTALLED_APPS = [
...
'lookout',
...
]
Step 3: Configure the API Endpoint¶
Add the API endpoint to urls.py
. This is where you’ll point report-uri
on the frontend.
Note
You can set the pattern to whatever you want.
Note
Be mindful of trailing slashes.
urlpatterns = [
...
# Django Lookout
url(r'^reporting', include('lookout.urls')),
...
]
Step 5: Configure CSP/HPKP¶
[To do]
Settings¶
TODO: List various settings and how they can be set in settings.py
.
API¶
-
class
lookout.
PackageVersion
[source]¶ Bases:
object
Attempts to determine the package’s version.
-
static
from_distribution
() → typing.Union[str, NoneType][source]¶ Gets the package version from its installed distribution using
pkg_resources
.
-
static
lookout.exceptions¶
-
exception
lookout.exceptions.
UnknownSchemaError
[source]¶ Bases:
Exception
Raised when a report doesn’t match any of the known schemas.
-
msg
= "The supplied JSON data doesn't match any known report schema."¶
-
-
exception
lookout.exceptions.
JSONDecodeError
(msg, doc, pos)[source]¶ Bases:
ValueError
Subclass of ValueError with the following additional properties:
msg: The unformatted error message doc: The JSON document being parsed pos: The start index of doc where parsing failed lineno: The line corresponding to pos colno: The column corresponding to pos
lookout.logging¶
lookout.models¶
-
class
lookout.models.
Report
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
A report filed through the HTTP Reporting API.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
body
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
created_time
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_next_by_created_time
(*, field=<django.db.models.fields.DateTimeField: created_time>, is_next=True, **kwargs)¶
-
get_next_by_incident_time
(*, field=<django.db.models.fields.DateTimeField: incident_time>, is_next=True, **kwargs)¶
-
get_previous_by_created_time
(*, field=<django.db.models.fields.DateTimeField: created_time>, is_next=False, **kwargs)¶
-
get_previous_by_incident_time
(*, field=<django.db.models.fields.DateTimeField: incident_time>, is_next=False, **kwargs)¶
-
get_type_display
(*, field=<django.db.models.fields.CharField: type>)¶
-
incident_time
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <lookout.models.ReportManager object>¶
-
schema
¶
-
type
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
url
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
uuid
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
lookout.urls¶
URL patterns for the API endpoint.
Add the endpoint to your urls.py
like so:
urlpatterns = [
...
# Django Lookout
url(r'^reporting', include('lookout.urls')),
...
]