Browse Source

more about forms

master
Julio Biason 9 years ago
parent
commit
401f04f94d
  1. 14
      django.html

14
django.html

@ -205,9 +205,13 @@ def get_product(request, product_id):
'product_info.html',
{'product': product})
else:
form = ProductForm(request)
if form.is_valid():
form.save()
return render(request,
'invalid.html',
{'reason': 'Can\'t create products yet'})
'product_info.html',
{'form': form})
</code></pre>
</section>
@ -223,7 +227,13 @@ def get_product(request, product_id):
<pre><code class="hljs">
{% extends 'base.html' %}
<ul>
{% if product %}
<li>Product name: {{ product.name }}</li>
{% endif %}
{% if form %}
{{ form }}
{% endif %}
</ul>
</code></pre>

Loading…
Cancel
Save