Bootstrap base navs in django for loop - python

I am trying to use base navs of bootstrap in django using for loop to display the summary and profile of book based on the book id. I am getting "Could not parse the remainder: '()' from 'book.objects.all()'" error. Please let me know if there is any other way to fix this. Can anyone please hint me how to go ahead?
book_review.html:-
{% extends 'books/base.html' %}
{% block content %}
<div class = "container">
<ul class = "nav nav-tabs" id = "myTab" role = "tablist">
<li class = "nav-item">
<a class = "nav-link active" id = "summary-tab" data-toggle = "tab"
href = "#summary" role = "tab" aria-controls = "summary"
aria-selected = "true">Summary</a>
</li>
<li class = "nav-item">
<a class = "nav-link" id = "profile-tab" data-toggle = "tab"
href = "#profile" role = "tab" aria-controls = "profile"
aria-selected = "false">Profile</a>
</li>
<li class = "nav-item">
<a class = "nav-link" id = "relatedbooks-tab" data-toggle = "tab"
href = "#relatedbooks" role = "tab" aria-controls = "relatedbooks"
aria-selected = "false">Related Books</a>
</li>
</ul>
<div class = "tab-content" id = "myTabContent">
<div class = "tab-pane fade show active" id = "summary" role = "tabpanel"
aria-labelledby = "summary-tab"><br><br>
{% for booksummary in book.objects.all() %}
{{booksummary.summary}}
{% endfor %}
</div>
<div class = "tab-pane fade" id = "profile" role = "tabpanel"
aria-labelledby = "profile-tab">
{% for bookprofile in book.objects.all() %}
<b><label for="title">Title:</label></b>
<p class="card-title">{{bookprofile.title}}</p>
<b><label for="author">Author:</label></b>
<p class="card-text">{{bookprofile.author}}</p>
<b><label for="release_date">Release Date:</label></b>
<p class="card-text">{{bookprofile.release_date}}</p>
<b><label for="language">Language:</label></b>
<p class="card-text">{{bookprofile.language}}</p>
<b><label for="genre">Genre:</label></b>
<p class="card-text">{{bookprofile.genre}}</p><br>
{% endfor %}
</div>
<div class = "tab-pane fade" id = "relatedbooks" role = "tabpanel"
aria-labelledby = "relatedbooks-tab">Content for related books tab</div>
</div>
<br>
<!-- jQuery library -->
<script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin = "anonymous">
</script>
<!-- Popper -->
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin = "anonymous">
</script>
<!-- Latest compiled and minified Bootstrap JavaScript -->
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous">
</script>
{% endblock %}
views.py:
def book_review(request,id):
book = get_object_or_404(Bookslist, id=id)
return render(request, "books/book_review.html", {'book': book})
models.py:
class Bookslist(models.Model):
title=models.CharField(max_length=30, unique=True)
author=models.CharField(max_length=30)
release_date= models.DateField()
language= models.CharField(max_length=30)
genre= models.CharField(max_length=30)
image= models.ImageField(upload_to='book_images/')
summary = models.TextField(blank=True, null=True)
def __str__(self):
return self.title
urls.py:
urlpatterns = [
path('admin/', admin.site.urls),
path('', views.home, name="Home"),
path('books/<int:id>/', views.book_review, name="book_review"),
path('about/', views.about, name="about"),
]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

You don't pass querysets like this in the template. If you want to show details of only one book then it should be
<div class = "tab-pane fade show active" id = "summary" role = "tabpanel" aria-labelledby = "summary-tab">
<br><br>
{{book.summary}}
</div>
<div class = "tab-pane fade" id="profile" role = "tabpanel" aria-labelledby = "profile-tab">
<b><label for="title">Title:</label></b>
<p class="card-title">{{book.title}}</p>
<b><label for="author">Author:</label></b>
<p class="card-text">{{book.author}}</p>
<b><label for="release_date">Release Date:</label></b>
<p class="card-text">{{book.release_date}}</p>
<b><label for="language">Language:</label></b>
<p class="card-text">{{book.language}}</p>
<b><label for="genre">Genre:</label></b>
<p class="card-text">{{book.genre}}</p>
<br>
</div>
If you want to show all the books then your view will be like this:
def book_review(request,id):
context ={}
book = get_object_or_404(Bookslist, id=id)
context['book'] = book
context['allBooks'] = Bookslist.objects.all()
return render(request, "books/book_review.html", context)
and then you will iterate over your book objects in template like this:
{% for b in allBooks %}
{{b.author}}
<!-- and so on for other attributes -->
{% endfor %}

Related

The 'poster' attribute does not have a file associated with it"

The following error occurs
The 'poster' attribute does not have a file associated with it
I don't quite understand what it may be related to and how to fix it
I tried to change the url value, but nothing worked.
html
<div class="container" style="grid-template-columns: repeat(auto-fill, 300px);">
for serial in serials %}
<div class="item">
<img src="{{ serial.poster.url }}" class="img-fluid" alt="">
<p>
{{ serial.title }}
</p>
</div>
endfor %}
</div>
views.py
class SerialDetailView(View):
def get(self, request):
serials = Serials.objects.all()
genres = Genre.objects.all()
return render(request, "serials/single_serial.html", {"serials": serials, "genres": genres})
urls.py
urlpatterns = [
path('register/', views.Register.as_view(), name='register'),
path('reg/', views.Reg.as_view(), name='reg'),
path("serials_list/", views.SerialsView.as_view(), name='serials_list'),
path("add/", views.AddView.as_view(), name='add'),
path("single_serial/", views.SerialDetailView.as_view(), name='single_serial'),
path("<slug:slug>/", views.SingleSerial.as_view(), name='detail_serial'),
path("actor/<int:id>/", views.ActorView.as_view(), name='actor_detail'),
]
My models
class Serials(models.Model):
title = models.CharField('Name',max_length=100)
description = models.CharField('Description', max_length= 200)
poster = models.ImageField('Poster', upload_to='serials/')
date = models.DateField('Date')
country = models.CharField('Страна',max_length=100)
actors = models.ManyToManyField(Actor, verbose_name='actors', related_name='actor')
genre = models.ManyToManyField(Genre, verbose_name='genres')
category = models.ForeignKey(Category, verbose_name='category', on_delete=models.SET_NULL, null=True)
url = models.SlugField(unique=False)
link = models.URLField(max_length=200, blank=True)
Because you are trying to display the image of one of the serials while you did not choose an image for it.
First, choose an image for all serials poster or use the following code:
<div class="container" style="grid-template-columns: repeat(auto-fill,
300px);">
for serial in serials %}
<div class="item">
{% if serial.poster %}
<img src="{{ serial.poster.url }}" class="img-fluid"
alt="">
{% endif %}
<p>
{{ serial.title }}
</p>
</div>
{% endfor %}
</div>

django error : NoReverseMatch at /watchlist/ Reverse for 'viewList' with arguments '('',)'

I am working on my project and the main idea is to add some items to the watchlist or "bookmark" some items:
when I render the page to see the watchlist that I add them by clicking on the "Add to watchlist button " Django give me this error:
NoReverseMatch at /watchlist/
Reverse for 'viewList' with arguments '('',)' not found. 1 pattern(s) tried: ['Post/(?P[0-9]+)$']
my code:
Model.py file
class Post(models.Model):
#data fields
title = models.CharField(max_length=64)
textarea = models.TextField()
#bid
price = models.FloatField(default=0)
currentBid = models.FloatField(blank=True, null=True)
imageurl = models.CharField(max_length=255, null=True, blank=True)
category = models.ForeignKey(Category, on_delete=models.CASCADE, default="No Category Yet!", null=True, blank=True)
creator = models.ForeignKey(User, on_delete=models.PROTECT)
date = models.DateTimeField(auto_now_add=True)
# for activated the Category
activate = models.BooleanField(default=True)
buyer = models.ForeignKey(User, null=True, on_delete=models.CASCADE, related_name="auctions_Post_creator")
############################### this is the watchers
watchers = models.ManyToManyField(User, blank=True, related_name='favorite')
def __str__(self):
return f"{self.title} | {self.textarea} | {self.date.strftime('%B %d %Y')}"
urls.py
urlpatterns =[
# Watchlist
path('Post/<int:id>/watchlist_post/change/<str:reverse_method>',
views.watchlist_post, name='watchlist_post'),
path('watchlist/', views.watchlist_list, name='watchlist_list')
path('Post/<int:id>', views.viewList, name='viewList'),
]
views.py
#start watchlist
def viewList(request, id):
# check for the watchlist
listing = Post.objects.get(id=id)
if listing.watchers.filter(id=request.user.id).exists():
is_watched = True
else:
is_watched = False
context = {
'listing': listing,
'comment_form': CommentForm(),
'comments': listing.get_comments.all(),
'Bidform': BidForm(),
# IS_WATCHED method
'is_watched': is_watched
}
return render(request, 'auctions/item.html', context)
#login_required
def watchlist_post(requset, id, reverse_method):
listing = get_object_or_404(Post, id=id)
if listing.watchers.filter(id=requset.user.id).exists():
listing.watchers.remove(requset.user)
else:
listing.watchers.add(requset.user)
if reverse_method == "viewList":
return viewList(requset, id)
return HttpResponseRedirect(reverse(reverse_method))
#login_required
def watchlist_list(request):
user = requset.user
watchers_items = user.favorite.all()
context = {
'watchers_items': watchers_items
}
return render(requset, 'auctions/watchlist.html', context)
HTML FILE: (item.html) this file for showing the post for exapmple : (title/ description/ date etc..)
<!-- check to add to watchlist -->
<div class="col">
{% if is_watched %}
Remove To Watchlist
<!-- remove it -->
{% else %}
Add To Watchlist
{% endif %}
</div>
HTML FILE (layout.html) for adding a link to the navbar for the page
<li class="nav-item">
<a class="nav-link" href="{% url 'watchlist_list' %}">Watchlist</a>
</li>
HTML FILE(whitchlsit page)
{% for post in watchers_items %}
<div class="col-sm-4">
<div class="card my-2">
<img src="{{post.imageurl}}" class="img-fluid">
<div class="card-body">
<div class="text-center py-2">
<h5 class="card-title text-info">{{post.title}}</h5>
<p class="alert alert-info">{{post.textarea}}</p>
<ul class="list-group">
<li class="list-group-item list-group-item-info">category: {{post.category.name}}</li>
<li class="list-group-item list-group-item-info">Price: {{post.price}}$</li>
<li class="list-group-item list-group-item-info">Created by: {{post.creator}}</li>
</ul>
</div>
<!-- Buttons -->
<div class="row">
<div class="col">
View
</div>
</div>
</div>
<div class="card-footer">
<small class="text-muted">Created since:{{post.date}}</small>
</div>
</div>
{% endfor %}
The culprit of this problem is that you are calling "{% url 'viewList' listing.id %}" even though viewList does not exist in your urls.py.
So, you can create one like this:
path("some/path", views.some_func, name="viewList")
EDIT
As the error says, listing.id is empty ({% url 'viewList' listing.id %}). So, you might want to do post.id instead because you are looping with the name of post.

Comment is not displaying in django after submission

I have tried to submit a comment from app rather than django admin. Comment is not displaying when submitted from my created app. But it is displaying when I add a comment from django admin app. May be I am doing something wrong in views.py file. Can anyone help me on this? Thank you.
views.py:
#login_required
def book_review(request,id):
book = get_object_or_404(Bookslist, id=id)
comment=Comment.objects.all().filter(post_id=id)
if request.method == 'POST':
form = CommentForm(request.POST)
if form.is_valid():
post = form.save(commit=False)
post.user_id = request.user
post.message= comment
post.save()
return redirect('book_review', id=id)
else:
form=CommentForm()
return render(request, "books/book_review.html", {'book':book, 'comment':comment, 'form': form})
models.py:
class Comment(models.Model):
message= models.TextField('Message',null=True)
date_comment=models.DateTimeField(default=now, null=True)
user_id= models.ForeignKey(User, on_delete=models.CASCADE,null=True)
post_id=models.ForeignKey(Bookslist,on_delete=models.CASCADE,null=True)
forms.py:
from django import forms
from .models import Comment
class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ['message', ]
book_review.html:
{% extends 'books/base.html' %}
{% load static %}
{% block stylesheet %}
<link rel="stylesheet" href="{% static 'accounts/accounts.css' %}">
{% endblock %}
{% block content %}
<div class = "container">
<ul class = "nav nav-tabs" id = "myTab" role = "tablist">
<li class = "nav-item">
<a class = "nav-link active" id = "summary-tab" data-toggle = "tab"
href = "#summary" role = "tab" aria-controls = "summary"
aria-selected = "true">Summary</a>
</li>
<li class = "nav-item">
<a class = "nav-link" id = "characters-tab" data-toggle = "tab"
href = "#characters" role = "tab" aria-controls = "characters"
aria-selected = "false">Characters</a>
</li>
<li class = "nav-item">
<a class = "nav-link" id = "relatedbooks-tab" data-toggle = "tab"
href = "#relatedbooks" role = "tab" aria-controls = "relatedbooks"
aria-selected = "false">Related Books</a>
</li>
</ul>
<div class = "tab-content" id = "myTabContent">
<div class = "tab-pane fade show active" id = "summary" role = "tabpanel"
aria-labelledby = "summary-tab"><br><br>
{{book.summary}}
</div>
<div class = "tab-pane fade" id = "characters" role = "tabpanel"
aria-labelledby = "characters-tab"><br><br>
{{book.c1}}<br><br>{{book.c2}}<br><br>{{book.c3}}<br><br>{{book.c4}}<br><br>{{book.c5}}<br><br>
{{book.c6}}<br><br>{{book.c7}}<br><br>{{book.c8}}<br><br>{{book.c9}}<br><br>
{{book.c10}}
</div>
<div class = "tab-pane fade" id = "relatedbooks" role = "tabpanel"
aria-labelledby = "relatedbooks-tab">Content for related books tab</div>
</div>
<br>
<br>
<div class="container">
<form method="post" class="mb-4">
{% csrf_token %}
<div class="form-group">
<label for="exampleFormControlTextarea1">Leave your comment:</label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-success">Post</button>
</form>
{% for com in comment %}
<div class="card mb-2">
<div class="card-body p-3">
<div class="row">
<div class="col-2">
<img src="{% static 'images/icon2.webp' %}" alt="{{ com.user_id }}" class="w-100">
<small>Posts: {{ com.count }}</small></div>
<div class="col-10">
<div class="row mb-3">
<div class="col-6">
<strong class="text-muted">{{ com.user_id }}</strong>
</div>
<div class="col-6 text-right">
<small class="text-muted">{{ com.date_comment }}</small>
</div>
</div>
{{ com.message }}<br><br>
{% if com.user_id == user %}
<button type="button" class="btn btn-primary">Reply</button>
{% endif %}
</div>
</div></div></div></div>
{% endfor %}
</div>
</div>
</div>
<!-- jQuery library -->
<script src = "https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin = "anonymous">
</script>
<!-- Popper -->
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin = "anonymous">
</script>
<!-- Latest compiled and minified Bootstrap JavaScript -->
<script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous">
</script>
{% endblock %}
You need to add the post_id to the newly created comment.
Like so:
post.post_id = id
Also make sure you are using the correct naming for your variables i believe post should be comment in this scenario based on the form being of CommentForm: model = Comment
This replacement would make for sense for the code:
if request.method == 'POST':
form = CommentForm(request.POST)
if form.is_valid():
comment = form.save(commit=False)
comment.user_id = request.user
comment.message= comment
comment.post_id = id
comment.save()

django view dont show anything

I'm working to create an event page in my Django work.
Although I wrote a code to obtain database data when I try to load the front page(from exhibition_view.html), just the exhibition.view_html loads and no article return and does not show in that page.
the weird thing is that seminar_view and exhibition_view are the same, and seminar_view does work!
I tried very much to solve the issue, but had no idea what is happening!
below is my code:
Model.py
from django.db import models
from django.utils import timezone
from tinymce.models import HTMLField
class EventType(models.Model):
name = models.CharField(max_length=20)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "Event Types"
def get_deleted_event_type():
return EventType.objects.get(name='no-category')
class Event(models.Model):
STATUS_CHOICES = (
('draft', 'Draft'),
('published', 'Published'),
)
EVENT_CHOICES = (
('seminar', 'seminar'),
('exhibition', 'exhibition'),
)
title = models.CharField(max_length=255)
slug = models.SlugField(max_length=250,
unique_for_date='publish', allow_unicode=True, unique=True)
body = HTMLField()
publish = models.DateTimeField(default=timezone.now)
created_on = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
events = models.ForeignKey(EventType, on_delete=models.SET(get_deleted_event_type))
event_type = models.CharField(max_length=15,
choices=EVENT_CHOICES,
default='seminar')
status = models.CharField(max_length=10,
choices=STATUS_CHOICES,
default='draft')
event_index = models.IntegerField()
class Meta:
ordering = ('-publish',)
verbose_name_plural = "Events"
def __str__(self):
return self.title
Views.py
from django.shortcuts import render
from .models import Event
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.db.models import Q
def seminar_detail(request, slug):
seminars = Event.objects.get(slug=slug)
context = {
'seminars': seminars
}
return render(request, "seminar_detail.html", context)
def exhibition_detail(request, events, slug):
cr1 = Q(events='2')
cr2 = Q(slug=slug)
exhibitions = Event.objects.get(cr1 & cr2)
context = {
'exhibitions': exhibitions
}
return render(request, "exhibition_detail.html", context)
def seminar_view(request):
criterion1 = Q(status='published')
criterion2 = Q(event_type="seminar")
seminars = Event.objects.filter(criterion1 & criterion2).order_by('event_index')
context = {
'seminars': seminars
}
return render(request, "seminar_view.html", context)
def exhibition_view(request):
criterion3 = Q(status='published')
criterion4 = Q(event_type="exhibition")
exhibitions_view = Event.objects.filter(criterion3 & criterion4).order_by('event_index')
context = {
'exhibitions_view': exhibitions_view
}
return render(request, "exhibition_view.html", context)
exhibition_view.html
{% extends 'base.html' %}
{% load static %}
<head>
<title>{% block title %}exhibitions{% endblock %}</title>
</head>
{% block page_content %}
<div class="page" id="page-container" >
<div class="top-bread">
<div class="breadcrumbs">
<ul>
<li class="home">
home
<span>»</span>
</li>
<li class="socialvoice">
<strong>exhibitions</strong>
</li>
</ul>
</div>
</div>
</div>
<div class="page">
<div class="main-container col1-layout">
<div class="main">
<div class="col-main">
<div class="shopbybrand-list">
<div class="brands">
<ul class="col">
{% for myevent in exhibitions_view %}
<li class="box">
<span>
<a href="{% url 'events:exhibition_view' event.slug %}">
<b>
<h2>{{ myevent.title }}<br/>{{ myevent.created_on.date }}</h2>
</b>
</a>
</span>
<b>
<p>
<p style="text-align: justify;">{{ myevent.body | safe | slice:":400" }}</p>
</p>
<a class="button" href="{% url 'events:exhibition_view' myevent.slug %}">
<span>
<span>ادامه مطلب</span>
</span>
</a>
</b>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
</div><!-- END page -->
{% endblock %}
and my app urls.py:
from django.urls import path
from . import views
from django.urls import re_path
app_name = 'events'
urlpatterns = [
path('seminar/', views.seminar_view, name="seminar_view"),
path('exhibition/', views.exhibition_view, name="exhibition_view"),
re_path(r'seminar/(?P<slug>[-\w]+)/', views.seminar_detail, name="seminar_detail"),
re_path(r'exhibition/(?P<slug>[-\w]+)/$', views.exhibition_detail, name="exhibition_detail"),
]

anchor tag doesn't submit items to cart python django

I have a dashboard of items displayed from my uniform model. I am attempting to send the item to a cart for checking out the item. I am not having issues loading my internal server, and I am getting no debugging issues. But when looking at my admin Order Item model, nothing has been pushed to it:
urls.py
from apparelapp import views
...
# TEMPLATE URLS
app_name = 'apparelapp'
urlpatterns = [
...
path('add_to_cart/<slug>/', views.add_to_cart, name="add_to_cart"),
...
]
views.py
# add to cart
def add_to_cart(request, slug):
item = get_object_or_404(Uniform, slug=slug)
order_item = OrderItem.objects.create(item = uniform)
order_qs = Transaction.objects.filter(user=request.user, ordered=False)
if order_qs.exists():
order = order_qs[0]
if transaction.items.filter(item__slug=item.slug).exists():
order_item.quantity += 1
order_item.save()
else:
transaction.item.add(item)
else:
ordered_date = timezone.now()
order = Transaction.objects.create(user=request.user, ordered_date = ordered_date)
order.items.add(order_item)
messages.success(request, "Added to cart!")
return redirect('apparelapp:item_list')
models.py
#OrderItem
class OrderItem(models.Model):
uniform = models.OneToOneField(Uniform, on_delete = models.PROTECT)
start_date = models.DateTimeField(auto_now_add=True)
ordered_date = models.DateTimeField(null = True)
quantity = models.IntegerField(default = 1)
def __str__(self):
return self.uniform.description
#Item
class Uniform(models.Model):
category = models.CharField(choices = CATEGORY_CHOICES, max_length=11)
description = models.CharField(max_length = 50)
price = models.FloatField(max_length = 6)
size = models.CharField(choices=CLOTHES_SIZE, max_length=4, blank=True)
style = models.CharField(choices=STYLE_CHOICES, max_length=15, blank=True)
image = models.ImageField(upload_to='uniforms/')
slug = models.SlugField()
class Meta:
ordering = ['category']
def __str__(self):
return '{}: {} - {} - ${}'.format(self.category, self.description, self.size, self.price)
def add_to_cart_url(self):
return reverse("apparelapp:add_to_cart", slug=slug)
html
<h2>List of items</h2>
<section class="text-center mb-4">
<div class="row wow fadeIn">
{% for item in object_list %}
<div class="col-lg-3 col-md-6 mb-4">
<div class="card">
<div class="view overlay">
<img src="{{ item.image.url }}" alt="Oh no!" width="200" height="200">
<a>
<div class="mask rgba-white-slight"></div>
</a>
</div>
<div class="card-body text-center">
<label>
<h5>{{ item.description }}</h5>
</label>
<h5>
{% if object.description %}
<strong>
<label for="">{{ item.category }}</label>
</strong>
{% endif %}
</h5>
<div class="row">
<div class="col-lg-2">
Size
</div>
<div class="col-lg-10">
Add to Cart
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
Initially I tried out the button once adding an item and it worked, but wouldn't add any additinoal items, now the link doesn't work as a whole. Am I missing something in my views.py?
You can easily use name attribute of path element of your urlpatterns list to navigate through project without changing url itself, if needed. To use this feature, you can specify url template tag with syntax like:
{{ url '<name_of_path_element>' arg1=arg.data }}
Where is name attribute of path element of your urlpatterns, like I said above; and arg1 is not required argument to pass as query string, and, arg.data is data to be passed.
HTML
<div class="col-lg-10">
Add to Cart
</div>
Please, let me know if it doesn't work.

Categories