Skip to main content

A template tag for making simulated GET requests to Django application view functions. The HTTP response can be displayed in the given template.

Variations of usage of viewssi:

{% viewssi path.to.view %}
{% viewssi path.to.view arg,arg2,kwarg=val %}
{% viewssi path.to.view arg,arg2,kwarg=val as var %}
{% viewssi path.to.view arg,arg2,kwarg=val get p1=v1,p2=v2 as var %}

The first argument is the path to a view function to call. If the view requires args and/or kwargs, pass them as the second token in the tag. args and the values of kwargs are resolved to template variables unless they are quoted.

The view doesn’t have to be exposed in a URL configuration. Essentially any function can be called that accepts one argument (the request) and returns a django.http.HttpResponse object.

You can pass a GET query string by including a get token in the tag followed by key=value pairs. Parameter values are also resolved to template variables unless they are quoted.

If the as <template-variable-name token of the tag is provided, the view’s response is assigned to the given template variable. Otherwise, the response content is returned in place.

When the response is assigned to a template variable, the http response is represented as a HttpResponseProxy object which contains a template-useable interface for fetching the response code, headers, and content. Examples:

{% ifequal response.status_code "200" %}
{{ response }}
{% endifequal %}

HttpResponseProxy behaves is a dict-like object. The http response headers are set as the dict items and their names are transposed for use in templates, i.e. ‘Content-type’ becomes ‘content_type’. For example:

{% ifequal response.content_type "text/html" %}
{% endifequal %}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-viewssi-0.1.tar.gz (8.4 kB view details)

Uploaded Source

File details

Details for the file django-viewssi-0.1.tar.gz.

File metadata

  • Download URL: django-viewssi-0.1.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-viewssi-0.1.tar.gz
Algorithm Hash digest
SHA256 2714b5459ad6856b96d43cdc9b4ffc75d7caf0bf67b8d1433fbde74de9b2ff47
MD5 d0c9645b5dec4619b62e7bd1dc0790ed
BLAKE2b-256 243844d8233ecb9af5afcb34f7ac4a9293633f7c0941ccf1a5cb3d53cd87c1d4

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.1

1 file

This release

0.1 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page