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 %}
    {% else %}
        <h3>You do not have permission to view this page</h3>
    {% endif %}
{% 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

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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



Asked: 08 Jul '13, 12:01

Seen: 2,220 times

Last updated: 08 Jul '13, 12:01

powered by OSQA