<div class="bg-body-tertiary p-5 rounded">
170 <div class ="header">{{header}}</div>
171 <a href="{% url 'issue_items' queryset %}"><div class = 'btn btn-danger'>ISSUE THIS ITEM</div></a>
172 <a href="receive"><div class = 'btn btn-primary'>RECEIVE THIS ITEM</div></a>
173 <br><br>
174 <div class = "display_table">
175 <tr>
176 <th>ITEM NAME</th>
177 <th>QUANTITY IN STORE</th>
178 <th>LAST UPDATED</th>
179 <th>REORDER LEVEL</th>
180 </tr>
181 <tr>
Side note: When posting code (or templates, error messages, tracebacks, etc), enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of `\``. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of editing your original post. Please remember to do this in the future.)
When requesting assistance with an error message, please post the complete traceback with the error from the console.
Basically, this error is telling you that “queryset” isn’t producing a valid value for the url in the url
tag. For us to get any more specific than that, we’ll need to see the view that is rendering that template.
def issue_items(request, pk):
queryset = Stock.objects.get(id=pk)
form = IssueForm(request.POST or None, instance=queryset)
if form.is_valid():
instance = form.save(commit=False)
instance.quantity -= instance.issue_quantity
messages.success(request, “Issued Successfully.” + str(instance.quantity) + " " + str(instance.item_name) + " s now left in store ")
instance.save()
return redirect(reverse(request,‘/stock_detail/’+str(instance.id)))
context = {
"title": 'issue' + str(queryset.item_name),
"queryset": queryset,
"form": form,
"username": 'Issue By:' + str(request.user)
}
return render(request, "add_items.html", context)