|
|
@ -79,12 +79,12 @@ |
|
|
|
|
|
|
|
|
|
|
|
<p> |
|
|
|
<p> |
|
|
|
Dentro do projeto, para criar um app: |
|
|
|
Dentro do projeto, para criar um app: |
|
|
|
</p> |
|
|
|
</p> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code class="hljs"> |
|
|
|
<pre><code class="hljs"> |
|
|
|
cd exemplo |
|
|
|
cd exemplo |
|
|
|
django-admin startapp [app] |
|
|
|
django-admin startapp [app] |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
<section> |
|
|
|
<section> |
|
|
@ -205,9 +205,13 @@ def get_product(request, product_id): |
|
|
|
'product_info.html', |
|
|
|
'product_info.html', |
|
|
|
{'product': product}) |
|
|
|
{'product': product}) |
|
|
|
else: |
|
|
|
else: |
|
|
|
|
|
|
|
form = ProductForm(request) |
|
|
|
|
|
|
|
if form.is_valid(): |
|
|
|
|
|
|
|
form.save() |
|
|
|
|
|
|
|
|
|
|
|
return render(request, |
|
|
|
return render(request, |
|
|
|
'invalid.html', |
|
|
|
'product_info.html', |
|
|
|
{'reason': 'Can\'t create products yet'}) |
|
|
|
{'form': form}) |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
</section> |
|
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
@ -223,7 +227,13 @@ def get_product(request, product_id): |
|
|
|
<pre><code class="hljs"> |
|
|
|
<pre><code class="hljs"> |
|
|
|
{% extends 'base.html' %} |
|
|
|
{% extends 'base.html' %} |
|
|
|
<ul> |
|
|
|
<ul> |
|
|
|
<li>Product name: {{ product.name }}</li> |
|
|
|
{% if product %} |
|
|
|
|
|
|
|
<li>Product name: {{ product.name }}</li> |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{% if form %} |
|
|
|
|
|
|
|
{{ form }} |
|
|
|
|
|
|
|
{% endif %} |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</code></pre> |
|
|
|
</code></pre> |
|
|
|
|
|
|
|
|
|
|
|