product detail
This commit is contained in:
parent
961b4b200b
commit
b46e94fda0
7
producthunt/static/bootstrap.min.css
vendored
Normal file
7
producthunt/static/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -15,6 +15,8 @@
|
|||||||
<!-- Bootstrap core CSS -->
|
<!-- Bootstrap core CSS -->
|
||||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
|
||||||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||||
|
<!-- Bootstrap core CSS. Adding local file enable pycharm to auto-complete CSS tags -->
|
||||||
|
<link href="{% static 'bootstrap.min.css' %}" rel="stylesheet">
|
||||||
<link href="{% static 'open-iconic/font/css/open-iconic-bootstrap.css' %}" rel="stylesheet">
|
<link href="{% static 'open-iconic/font/css/open-iconic-bootstrap.css' %}" rel="stylesheet">
|
||||||
|
|
||||||
<!-- Favicons -->
|
<!-- Favicons -->
|
||||||
|
40
products/templates/products/detail.html
Normal file
40
products/templates/products/detail.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% block content %}
|
||||||
|
{% if error %}
|
||||||
|
{{ error }}
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
{% endif %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2">
|
||||||
|
<img src="{{ product.icon.url }}" class="img-fluid" \>
|
||||||
|
</div>
|
||||||
|
<div class="col-10">
|
||||||
|
<a href="{{ product.url }}"><h1>{{ product.title }}</h1></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8">
|
||||||
|
<img src="{{ product.image.url }}" class="img-fluid" \>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<a href=""><button class="btn btn-primary btn-lg btn-block"><span class="oi oi-caret-top"></span> Up Vote : {{ product.votes_total }}</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4">
|
||||||
|
<h4>Hunted by: {{ product.hunter.username }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="col-4 text-right">
|
||||||
|
<h4>{{ product.pubdate_pretty }}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8">
|
||||||
|
<p>{{ product.body }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
@ -3,4 +3,5 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('create', views.create, name='create'),
|
path('create', views.create, name='create'),
|
||||||
|
path('<int:product_id>/', views.detail, name='detail'),
|
||||||
]
|
]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from .models import Product
|
from .models import Product
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@ -25,8 +25,13 @@ def create(request):
|
|||||||
product.pubdate = timezone.datetime.now()
|
product.pubdate = timezone.datetime.now()
|
||||||
product.hunter = request.user
|
product.hunter = request.user
|
||||||
product.save()
|
product.save()
|
||||||
return redirect('home')
|
return redirect('/products/' + str(product.id))
|
||||||
else:
|
else:
|
||||||
return render(request, 'products/create.html', {'error': 'all fields required'})
|
return render(request, 'products/create.html', {'error': 'all fields required'})
|
||||||
else:
|
else:
|
||||||
return render(request, 'products/create.html')
|
return render(request, 'products/create.html')
|
||||||
|
|
||||||
|
|
||||||
|
def detail(request, product_id):
|
||||||
|
product = get_object_or_404(Product, pk=product_id)
|
||||||
|
return render(request, 'products/detail.html', {'product': product})
|
||||||
|
Loading…
Reference in New Issue
Block a user