Skip to content

Instantly share code, notes, and snippets.

@joshkehn
Created January 28, 2014 02:49
Show Gist options
  • Save joshkehn/8661501 to your computer and use it in GitHub Desktop.
Save joshkehn/8661501 to your computer and use it in GitHub Desktop.
def some_view (request):
# Could substitute `None` with some other default value
key = request.POST.get("key", None)
return render(request, "mytemplate.html", {"key": key})
# In mytemplate.html you'll now have `key` available with whatever was submitted via the form. Note
# that there is NO validation here, you should probably be using a form to capture the input,
# validate it, and return it. https://docs.djangoproject.com/en/dev/ref/forms/api/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment