Skip to content

Instantly share code, notes, and snippets.

@venkatesh22
Forked from srstanic/js_handlers.py
Created July 11, 2013 14:34
Show Gist options
  • Save venkatesh22/5976005 to your computer and use it in GitHub Desktop.
Save venkatesh22/5976005 to your computer and use it in GitHub Desktop.
'''
templatetags module
'''
from django import template
register = template.Library()
@register.simple_tag
def go_to_url(url):
return "window.location='" + url +"'; return false;"
<form action="/objects/create" method="post">{% csrf_token %}
{{ form }}
<button onclick="{% go_to_url '/objects' %}">Cancel</button>
<button type="submit">Report</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment