add a view to show the details of an article
This commit is contained in:
parent
7c5af973f2
commit
6894a1bfba
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="content" class="flex">
|
||||||
|
<h1>{{ article.name }}</h1>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>{{ article.description }}</p>
|
||||||
|
<p><b>Stock:</b> {{ article.stock }}</p>
|
||||||
|
<p><b>Status:</b> {{ article.status}}</p>
|
||||||
|
<p><b>Price:</b> {{ article.price_in_chf }}</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -4,6 +4,9 @@ from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.index, name='index'),
|
url(r'^$', views.index, name='index'),
|
||||||
|
url(r'^details/(?P<article_id>[0-9]+)/$',
|
||||||
|
views.article_details,
|
||||||
|
name='details'),
|
||||||
url(r'^category/(?P<category_id>[0-9]+)/$',
|
url(r'^category/(?P<category_id>[0-9]+)/$',
|
||||||
views.articles_in_category,
|
views.articles_in_category,
|
||||||
name='category'),
|
name='category'),
|
||||||
|
|
|
@ -36,3 +36,10 @@ def articles_in_category(request, category_id):
|
||||||
'category': selected_category,
|
'category': selected_category,
|
||||||
}
|
}
|
||||||
return HttpResponse(template.render(context, request))
|
return HttpResponse(template.render(context, request))
|
||||||
|
|
||||||
|
|
||||||
|
def article_details(request, article_id):
|
||||||
|
article = get_object_or_404(Article, pk=article_id)
|
||||||
|
return render(request,
|
||||||
|
'webshop/article_details.html',
|
||||||
|
{'article': article})
|
||||||
|
|
Loading…
Reference in New Issue