diff --git a/products/templates/products/detail.html b/products/templates/products/detail.html
index ce5e469..ad6e1c2 100644
--- a/products/templates/products/detail.html
+++ b/products/templates/products/detail.html
@@ -19,7 +19,7 @@
@@ -37,4 +37,10 @@
{{ product.body }}
+
+
+
{% endblock %}
diff --git a/products/urls.py b/products/urls.py
index 58a455c..a4ecbd5 100644
--- a/products/urls.py
+++ b/products/urls.py
@@ -4,4 +4,5 @@ from . import views
urlpatterns = [
path('create', views.create, name='create'),
path('/', views.detail, name='detail'),
+ path('/upvote', views.upvote, name='upvote'),
]
diff --git a/products/views.py b/products/views.py
index 7a1b852..ffd1cf3 100644
--- a/products/views.py
+++ b/products/views.py
@@ -35,3 +35,12 @@ def create(request):
def detail(request, product_id):
product = get_object_or_404(Product, pk=product_id)
return render(request, 'products/detail.html', {'product': product})
+
+
+@login_required()
+def upvote(request, product_id):
+ if request.method == 'POST':
+ product = get_object_or_404(Product, pk=product_id)
+ product.votes_total += 1
+ product.save()
+ return redirect('/products/' + str(product.id))