Django Smithy¶
Contents:
Django Smithy¶
Craft HTTP requests in the Django Admin. Django Smithy is an HTTP Request templating system that allows developers to build systems to send abstract messages without additional development.
Documentation¶
The full documentation is at https://django-smithy.readthedocs.io.
Quickstart¶
Install Django Smithy:
pip install django-smithy
Then, create a request template to send:

Features¶
- Design requests in the Django Admin panel
- Send requests with whatever context you’d like
- Use Django’s templating system everywhere
- Define variables to be added to the context
Running Tests¶
Does the code actually work?
source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox
Installation¶
At the command line:
$ easy_install django-smithy
Or, using pip:
$ pip install django-smithy
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv django-smithy
$ pip install django-smithy
Usage¶
Before sending requests, you must first create a blueprint. Request blueprints drive all the requests sent through Django Smithy.
Once a blueprint is created, you can call the send
method and provide a dictionary of context. This context will be passed to all properties of the request and interpreted using Django’s template language.
Django template syntax is supported in pretty much everything, including the name and value of headers, cookies, and query parameters, as well as the request body and URL. This makes it easy to make dynamic requests that contain contextual data.
Variables are just static values that allow you to easily reuse or swap out data without needing to provide it in code. This is great for storing things like API keys, but it’s important to note the security impacts of this, as the API key will be visible in plain text to any user with access to this section of the Django Admin.
# Retrieve the blueprint
# (will change depending on your use case)
blueprint = RequestBlueprint.objects.first()
# Send the request and get the record
record = blueprint.send(context = {
'something': 'some value',
'more_stuff': 0
})
# Or get all records for that blueprint
RequestRecord.from_blueprint(blueprint)
Once sent, a request will generate a RequestRecord with details of the response. The RequestRecord can be used to determine if a request failed or not and handle appropriately.