Can I use a Django template tag to evaluate a conditional based on a form being submitted?

Here's my HTML template form:

{% block newstory %}
<div class="well">
    {% if user.is_staff %}
    {% if article %}
        <h1>Edit Story {{ article }}</h1>
    {% else %}
        <h1>Create new story</h1>
    {% endif %}
    <form action="" method="POST" enctype="multipart/form-data">
        {% csrf_token %}
        {{ form|as_bootstrap }}
        {% if form.is_published %}
        <input type="submit" name="submit" value="Save">
        {% else %}
        <input type="submit" name="submit" value="Save">
        {% endif %}
    </form>
    {% else %}
        <h3>You do not have permission to view this page</h3>
    {% endif %}
</div>
{% endblock %}

I want to add this little JavaScript inline:

onClick="if(confirm('Are you sure?')) alert('Article has been emailed to clients'); else alert('Article was not sent')"

if the form being submitted has the is_published Boolean set to True. Can I do that with a template tag and an HTML form?

asked 08 Jul '13, 12:01

AnthonyBRoberts's gravatar image

AnthonyBRoberts
112
accept rate: 0%

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×5
×3

Asked: 08 Jul '13, 12:01

Seen: 2,135 times

Last updated: 08 Jul '13, 12:01

powered by OSQA