Files
django-signposting/django_signposting/utils.py
2024-11-01 13:02:56 +01:00

17 lines
500 B
Python

from django.http import HttpResponse
from signposting import Signpost
def add_signposts(response: HttpResponse, *args: Signpost):
""" Adds signposting headers to the responses.
params:
response - the response object
args - a list of signposts to add to this resposnse.
"""
if not hasattr(response, '_signposts'):
response._signposts = []
for signpost in args:
if not signpost in response._signposts:
response._signposts.append(signpost)