A signed Django form
Project description
A small library that provides a form class that signs a configurable set of hidden fields using django.core.signing.
The most common use case for such a form is when the view that handles the post differs from the view that sets up the form, but you need to pass some information from one view to the other, without evil hackers tampering with your precious data.
Usage
Subclass SignedForm, and define which fields should be signed:
from signedforms.forms import SignedForm class MyForm(SignedForm): signed_fields = ['redirect_url',] redirect_url = forms.CharField(required=False, widget=forms.HiddenInput)
In the form that sets up the view, provide the data to be signed in the initial dictionary:
my_form = MyForm(initial={'redirect_url': self.request.path_info})
and in the view that handles the posted form:
def form_valid(self, form): # do some work return HttpResponseRedirect(form.cleaned_data['redirect_url'])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-signedforms-0.2.tar.gz
.
File metadata
- Download URL: django-signedforms-0.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a54511a8dd80fbf65f7d147ee042d6d30e2a225688d78478fc821d56c61f00b |
|
MD5 | 7b46610813e4281551a7347af091d7fe |
|
BLAKE2b-256 | fd7cab7e420ed3f7865c1eb23034fecdc4a84828f0e337ec65fd60effaa37c41 |