Form not displaying on Django site - django

I have just started learning Django and I have hit a little snag and was hoping someone could help.
Problem:
My form is not displaying in my main HTML template (ingredior.html) but the form will display in my test HTML template (test.html) which is just a boiler plate HTML file with the {{form1}} tag in the body. I am changing "return render(request, 'ingredior/ingredior.html', context)" in the views.py file manually to test the two different HTML templates.
ingredior.html
test.html
Question:
Why is the form working in the test.html and not the ingredior.html file when changed?
Please keep in mind that I am swapping this line of code "return render(request, 'ingredior/ingredior.html', context)" with "return render(request, 'ingredior/test.html', context)" to test between the two.
CODE---------
Forms.py
from django import forms
class UserInput(forms.Form):
base_search_ingredient = forms.ChoiceField(choices=[('vegan', 'Vegan'), ('vegatarian', 'Vegatarian')])
views.py
from django.shortcuts import render
import requests
from .local_api_key import Key
from .forms import UserInput
def index (request):
app_id = Key.app_id
app_key = Key.app_key
search_from = 0
search_to = 100
form1 = UserInput()
test = []
if request.POST.get('search'):
test2 = request.POST.get('search')
intolerance = test2
url = requests.get(f"https://api.edamam.com/search?q={intolerance}&excluded=egg&excluded=beef&excluded=dairy&excluded=tomato&excluded=cherry%20tomatoes&excluded=rice&excluded=corn&excluded=soy&excluded=onion&from={search_from}&to={search_to}&health={intolerance}&app_id={app_id}&app_key={app_key}").json()
recipe_length = (len(url['hits']))
else:
intolerance = 'vegan'
url = requests.get(f"https://api.edamam.com/search?q={intolerance}&excluded=egg&excluded=beef&excluded=dairy&excluded=tomato&excluded=cherry%20tomatoes&excluded=rice&excluded=corn&excluded=soy&excluded=onion&from={search_from}&to={search_to}&health={intolerance}&app_id={app_id}&app_key={app_key}").json()
recipe_length = (len(url['hits']))
for urls in range(recipe_length):
recipe_name = (url['hits'][urls]['recipe']['label'])
recipe_url = (url['hits'][urls]['recipe']['url'])
recipe_image = (url['hits'][urls]['recipe']['image'])
recipe_healthLabels = (url['hits'][urls]['recipe']['healthLabels'])
recipe_ingredients = (url['hits'][urls]['recipe']['ingredientLines'])
test.append((recipe_name, recipe_url, recipe_image, recipe_healthLabels, recipe_ingredients))
context = {'test': test, 'form1': form1}
return render(request, 'ingredior/ingredior.html', context)
ingredior.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Nake Recipes</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href=>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<style>
.card {
width: 300px;
height: 700px;
overflow: scroll;
float: left;
margin: 13px;
}
.list {
line-height: 2em;
text-align: left;
}
.card-content ul {
height: 100px
overflow-y: scroll;
}
.container h1 {
text-align: center;
}
</style>
</head>
<body>
<nav>
<div class="container nav-wrapper">
Naked Recipes
<ul id="nav-mobile" class="right">
<li>Home</li>
</ul>
</div>
</nav>
<div class="container">
<h1 style="text-align: c">What intolerance do you have?</h1>
<div class="row">
<div class="col s4">
<!-- Promo Content 1 goes here -->
<div class="center">
<i class="large material-icons" style="color: #EE6E73">flash_on</i>
<p></p>
<p class="light center"></p>
</div>
</div>
<div class="col s4">
<!-- Promo Content 2 goes here -->
<div class="center">
<i class="large material-icons" style="color: orange">camera</i>
<p></p>
<p class="light center"></p>
</div>
</div>
<div class="col s4">
<!-- Promo Content 3 goes here -->
<div class="center">
<i class="large material-icons" style="color: blue">chrome_reader_mode</i>
<p></p>
<p class="light center"></p>
</div>
</div>
</div>
<br>
<form action="" method="post">
{% csrf_token %}
{{ form1 }}
</form>
<br>
<div class="row">
{% for item in test %}
<div class="col_s2">
<div class="card">
<div class="card-image">
<img src= {{ item.2 }} alt="">
</div>
<div class="card-content scroll">
{{ item.0 }}<br><br>
<p>
<b>Ingredients</b><br>
</p>
<ul class="list">
{% for litem in item.4 %}
<li>- {{ litem }}</li>
{% endfor %}
</ul>
<ul class="list">
<p>
<b>Allergies</b>
</p>
{% for litem in item.3 %}
<li>- {{ litem }}</li>
{% endfor %}
</ul>
</div>
<div class="card-action">
<a href={{ item.1 }}>Get Full Recipe </a>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
</html>
test.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="" method="post" >
{% csrf_token %}
{{ form1 }}
</form>
</body>
</html>
app/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name="index"),
]
Thank you in advance 😅
** UPDATE **
On further investigation :
Inspection Image ingredior.html
Inspection Image test.html
They are the same.

Related

is the any other way to upload image from frontend using upload section ? getting not displayed and upload from index.html page

I have tried to upload the image from the index.html page and also created; modles.py, views.py, urls.py and soon but I have upload and it is successfully uploaded in the mentioned directory in models.py but failed to view that image in front showing cut pic image
views.py
from django.shortcuts import render
from django.http import HttpResponseRedirect
from .models import Upload
# Create your views here.
# Imaginary function to handle an uploaded file
def Home(request):
if request.method == 'POST':
photo = request.POST['doc']
Upload.objects.create(document = photo)
context ={
}
if request.method == "GET":
photo = Upload.objects.all()
context = {
'phone': photo
}
return render(request, 'Home.drive.html', context)
models.py
from django.db import models
# Create your models here.
class Upload(models.Model):
document = models.ImageField(upload_to='documents')
index.html
{% load static %}
<!DOCTYPE html>
{% block content %}
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>PB-2021</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="{% static 'css/index.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap-5.css' %}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
</head>
<body>
<nav style="font-size: 1em;
list-style-type: none;
display: block;
margin: 0;
padding: 0;
overflow: hidden;
position: sticky;
top: 0;
z-index: 1;">
<input type="checkbox" id="check">
<label for="check" class="checkbtn">
<i class="fas fa-bars"></i>
</label>
<label class="logo">AMRIT SHAHI</label>
<ul>
<li><a class="active" href="{% url 'PBAPP:home' %}">Home</a></li>
<li>About</li>
<li>Services</li>
<li>Pages</li>
<li>Contact</li>
</ul>
</nav>
<form method="POST" action="">
{% csrf_token %}
<div style="float: right;">
<label for="formFileLg" class="form-label">* File Upload</label>
<input class="form-control form-control-lg" id="formFileLg" type="file" name="doc">
<input type="submit" class="form-control form-control-lg" id="formFileLg" style="height: 10px; margin-top: 10px; background-color: #e9ecef;"/>
<hr style="width: 100%;">
</div>
</form>
<hr>
{% for i in phone %}
<img src="{{i.document.url}}" alt="Girl in a jacket" width="200" height="200; display: flex;">
{% endfor %}
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<footer class="bg-light text-center text-lg-start" style="width: 100%;">
<!-- Copyright -->
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2);">
© 2021 Copyright:
<a class="text-dark" href="https://theme.euesk.com">theme.euesk.com</a>
</div>
<!-- Copyright -->
</footer>
<script src="{% static 'js/bootstrap-5.js' %}"></script>
</body>
</html>
{% endblock %}
*Notes: help appreciated, my output is image icon only not the actual image
#Edit this thing first in the form
<form method="POST" action="" enctype="multipart/form-data">
# This thing in the views.py
def Home(request):
photo = ""
if request.method == 'POST':
photo = request.FILES['doc']
Upload.objects.create(document = photo)
if request.method == "GET":
photo = Upload.objects.all()
context = {
'phone': photo
}
For any further issue, let me know.

Why bootstrap carousel and django not workig properly?

I am trying to provide bootstrap carousel backend with django.I have written a simple program view which will pass all images to template.But when i run the program i did't get output as expected, all images are rendered adjecent to one other. There was nothing like forward and backward button and all.And i am posting my view and template.
Thanks in advance.
Hope to here from you soon.
View:-
def TaggingView(request):
queryset = MyImage.objects.filter(is_tagged=False)
return render(request, "taggging.html", {'files': queryset})
Template :-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div id="carouselInd" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
{% for file in files %}
{% with forloop.counter0 as i %}
<div class="carousel-item {% if i is 0 %}active{% endif %}">
<img class="d-block w-100" src="{{ file.image.url }}" alt="" style="height: 30rem;">
</div>
{% endwith %}
{% endfor %}
</div>
<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</body>
</html>
output:-
Django work fine with Bootstrap carousel, you need to be aware with the active class like this :
<div id="carouselInd" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
{% for file in files %}
{% with forloop.counter0 as i %}
<div class="carousel-item {% if i is 0 %}active{% endif %}">
<img class="d-block w-100" src="{{ file.image.url }}" alt="
{{ file.name }}" style="height: 30rem;">
</div>
{% endwith %}
{% endfor %}
</div>
</div>
NB : The alt attribute is dynamic, you can use a static value if you want. And give a height to the image can help to contain the image too.

Page not found error / url is not working with pk

I m working on learning Django with MDN project on Local Library.
My two pages are rendering whereas the book detail page is not rendering and giving error page not found. Please advice what if I have missed anything:
So far entire project is on MDN documents.
catalog/urls.py
from django.urls import path
from catalog import views
app_name = 'catalog'
urlpatterns = [
path('', views.index, name='index'),
path('books/', views.BookListView.as_view(), name='books'),
path('book/<int:pk>', views.BookDetailView.as_view(), name='book-detail'),
]
catalog/templates/catalog/book_detail.html
{% extends 'catalog/base.html' %}
{% block content %}
<h1>Title: {{ book.title }}</h1>
<p><strong>Author:</strong> {{ book.author }}</p>
<p><strong>Summary:</strong> {{ book.summary }}</p>
<p><strong>ISBN:</strong> {{ book.isbn }}</p>
<p><strong>Language:</strong> {{ book.language }}</p>
<p><strong>Genre:</strong> {{ book.genre.all|join:", " }}</p>
<div style="margin-left:20px;margin-top:20px">
<h4>Copies</h4>
{% for copy in book.bookinstance_set.all %}
<hr>
<p class="{% if copy.status == 'a' %}text-success{% elif copy.status == 'd' %}text-danger{% else %}text-warning{% endif %}">{{ copy.get_status_display }}</p>
{% if copy.status != 'a' %}<p><strong>Due to be returned:</strong> {{copy.due_back}}</p>{% endif %}
<p><strong>Imprint:</strong> {{copy.imprint}}</p>
<p class="text-muted"><strong>Id:</strong> {{copy.id}}</p>
{% endfor %}
</div>
{% endblock %}
catalog/templates/catalog/base.html
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="{% static 'catalog/style.css' %}">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" crossorigin="anonymous"/>
{% block title %}
<title></title>
{% endblock %}
</head>
<body>
<header>
<div class="container-fluid">
<div class="row">
<div class="col-sm-2">
{% block sidebar %}
<ul class="sidebar-nav list-inline1 p-2">
<li class="list-inline-item1">Home</li>
<li class="list-inline-item1">All books</li>
<li class="list-inline-item1">All authors</li>
</ul>
{% endblock %}
</div>
</div>
</div>
</header>
<div class="container-fluid">
<div class="row">
<div class="col-md-10">
{% block content %}
{% endblock %}
</div>
</div>
</div>
<!-- Optional JavaScript; choose one of the two! -->
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-p34f1UUtsS3wqzfto5wAAmdvj+osOnFyQFpp4Ua3gs/ZVWx6oOypYoCJhGGScy+8" crossorigin="anonymous"></script>
</body>
</html>

How to save data in django models taken from bootstrap form?

I'm new in Django and now I'm working on my first project.
I created model 'nom' to store data and also bootstrap form in html temlplate.
My question is how can I save data in my model after clicking submit button in my form in html.
All answers i have found recommended me to create Form as class.
Is any easy way to use data from my form?
Thanks
home.html
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<title>Title</title>
<style>
body { margin: 40px }
.my-container {
border: 1px solid green}
.my-row {
border: 2px solid blue}
.my-col {
border: 2px solid red}
btn-primary { margin-left: 50px}
.align-right {
text-align: center;
border: 0;
}
</style>
</head>
<body>
<div class="container my-container">
<form action="{% url 'home' %}" method="Post">
{% csrf_token %}
<div class= "row my-row">
<div class="col-3 my-col">
<input type="number" placeholder="0" name="nom200" size="1" />
</div>
<div class="col my-col">
<h3><span class="badge badge-secondary"> {% if liczba %}
{{ liczba }}
{% endif %}
</span></h3>
</div>
<div class="col my-col">
<h3><span class="badge badge-secondary"> {% if ls %}
{{ ls }}
{% endif %}
</span></h3>
</div>
</div>
<div class= "row my-row">
<div class="col-3 my-col">
<input type="number" placeholder="0" name="nom100" size="1" />
</div>
<div class="col my-col">
<h3><span class="badge badge-secondary"> {% if liczba1 %}
{{ liczba1 }}
{% endif %}
</span></h3>
</div>
<div class="col my-col">
<h3><span class="badge badge-secondary"> {% if ls1 %}
{{ ls1 }}
{% endif %}
</span></h3>
</div>
</div>
<div class= "row my-row">
<div class="col-3 my-col">
<input type="number" placeholder="0" name="nom50" size="1" />
</div>
<div class="col my-col">
<h3><span class="badge badge-secondary"> {% if liczba3 %}
{{ liczba3 }}
{% endif %}
</span></h3>
</div>
<div class="col my-col">
<h3><span class="badge badge-secondary" name="superowo"> {% if ls3 %}
{{ ls3 }}
{% endif %}
</span></h3>
</div>
</div>
<div class= "row my-row">
<div class="col-3 my-col">
</div>
<div class="col my-col">
<h3><span class="badge badge-secondary"> {% if suma %}
{{ suma }}
{% endif %}
</span></h3>
</div>
</div>
<input type="submit" class="btn" value="Click" href="{% url 'home'%}" name="print_btn">
<a class="btn btn-primary" type="submit" href="{% url 'some_view'%}" >Do PDF</a>
<div class="align-right">
</div>
</form>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
</body>
models.py
from django.db import models
class nom (models.Model):
nom200=models.Field(max_length=200)
nom100 = models.CharField(max_length=200)
nom50 = models.CharField(max_length=200)
views.py
from django.shortcuts import render
from . import slownie
from .models import nom
def home (request):
ls=''
ls1=''
ls3=''
liczba= request.POST.get("nom200")
liczba1=request.POST.get("nom100")
liczba3=request.POST.get("nom50")
if liczba and liczba.isdigit():
liczba=int(liczba)*200
ls=slownie.slownie(int(liczba))
if liczba1 and liczba1.isdigit():
liczba1=int(liczba1)*100
ls1=slownie.slownie(int(liczba1))
if liczba3 and liczba3.isdigit():
liczba3=int(liczba3)*50
ls3=slownie.slownie(int(liczba3))
suma=0
if liczba1 and liczba and liczba3:
suma=int(liczba)+int(liczba1)+int(liczba3)
nom200=liczba
nom100=liczba1
nom50=liczba3
return render(request, 'home.html',{'liczba':liczba,'liczba1':liczba1,'liczba3':liczba3,
'suma':suma,
'ls':ls,
'ls1':ls1,
'ls3':ls3})
You save it in a model:
# …
nom200=liczba
nom100=liczba1
nom50=liczba3
nom.objects.create(
nom200=nom200
nom100=nom100
nom50=nom50
)
Normally Django models are however written in PerlCase, so Nom, instead of nom, this is often a good idea to prevent name clashes with object, that often use the name of the model, but in snake_case.

Django Python DetailView not working as expected. I get an issue when I try and view a specific note

Advice required. would someone point me in the right direction?
Using Django 3.1.1 with Pycharm Community 2020.2
I'm working with ListView to show all To-Do notes on one page
allTasks.html
{% extends "app/base.html" %}
{% load static %}
{% block content %}
<body>
<div class="section">
<div class="container" id="heading">
<h3>List of all Tasks to-date</h3>
</div>
<div class="container">
<ul id="taskcontainer">
{% for i in obj %}
<li>
<div class="row">
<div class="col-md-12">
<div class="row no-gutters border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-inblock">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-primary">{{ i.name }}</strong>
<h6 class="mb-0">{{ i.date }}</h6>
<div class="mb-1 text-muted">Team {{ i.team_project }}</div>
<p class="card-text mb-auto">{{ i.notes }}</p>
<p class="card-text mb-auto">Priority: {{ i.urgency }}</p>
<strong class="d-inline-block mb-2 text-danger">Completed? {{ i.completed }}</strong>
<span>
View
Edit
</span>
</div>
</div>
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
</body>
From here I go into DetailView to each individual note
task_detail.html
{% extends "app/base.html" %}
{% load static %}
{% block content %}
<br>
<div class="row">
<div class="col-md-12">
<div class="row no-gutters border rounded overflow-hidden flex-md-row mb-4 shadow-sm h-md-250 position-inblock">
<div class="col p-4 d-flex flex-column position-static">
<strong class="d-inline-block mb-2 text-primary">{{ object.name }}</strong>
<h6 class="mb-0">{{ object.date }}</h6>
<div class="mb-1 text-muted">Team {{ object.team_project }}</div>
<p class="card-text mb-auto">{{ object.notes }}</p>
<p class="card-text mb-auto">Priority: {{ object.urgency }}</p>
<strong class="d-inline-block mb-2 text-danger">Completed? {{ object.completed }}</strong>
<strong class="d-inline-block mb-2 text-danger">Overdue? {{ object.overdue }}</strong>
</div>
</div>
</div>
</div>
{% endblock content %}
Here is my views.py
def task(request):
form = TasksForm()
if request.method == 'POST':
form = TasksForm(request.POST or None)
if form.is_valid():
form.save()
messages.success(request, 'Task has been saved!')
return render(request, 'app/tasks.html', {'form': form})
else:
return render(request, 'app/tasks.html', {'form': form})
class TaskListView(ListView):
model = Task
template_name = 'app/allTasks.html' # <app> / <model>_<viewtype>.html
context_object_name = 'obj'
ordering = ['-date'] # ordering by date
class TaskDetailView(DetailView):
model = Task
urls.py
urlpatterns = [
path('', views.index, name='index'),
path('task/', views.task, name='tasks'),
path('allTasks/', TaskListView.as_view(), name='allTasks'),
path('task/<int:pk>/', TaskDetailView.as_view(), name='task-detail'),
]
my issue as below
NoReverseMatch at /allTasks/
Reverse for 'task-detail' with arguments '('',)' not found. 1 pattern(s) tried: ['task/(?P<pk>[0-9]+)/$']
Request Method: GET
Request URL: http://127.0.0.1:8000/allTasks/
Django Version: 3.1.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'task-detail' with arguments '('',)' not found. 1 pattern(s) tried: ['task/(?P<pk>[0-9]+)/$']
Exception Location: C:\Users\mackm\PycharmProjects\IT6041-Project\venv\lib\site-packages\django\urls\resolvers.py, line 685, in _reverse_with_prefix
Python Executable: C:\Users\mackm\PycharmProjects\IT6041-Project\venv\Scripts\python.exe
Python Version: 3.8.5
Python Path:
['C:\\Users\\mackm\\PycharmProjects\\IT6041-Project\\IT6041_Project_Folder',
'C:\\Users\\mackm\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip',
'C:\\Users\\mackm\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs',
'C:\\Users\\mackm\\AppData\\Local\\Programs\\Python\\Python38-32\\lib',
'C:\\Users\\mackm\\AppData\\Local\\Programs\\Python\\Python38-32',
'C:\\Users\\mackm\\PycharmProjects\\IT6041-Project\\venv',
'C:\\Users\\mackm\\PycharmProjects\\IT6041-Project\\venv\\lib\\site-packages']
Server time: Mon, 12 Oct 2020 03:48:26 +0000
Error during template rendering
In template C:\Users\mackm\PycharmProjects\IT6041-Project\IT6041_Project_Folder\app\templates\app\base.html, error at line 22
Reverse for 'task-detail' with arguments '('',)' not found. 1 pattern(s) tried: ['task/(?P<pk>[0-9]+)/$']
12 <link rel="canonical" href="https://getbootstrap.com/docs/4.5/examples/album/">
13
14 <!-- Bootstrap core CSS -->
15 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
16 integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
17 <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
18 integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
19 crossorigin="anonymous"></script>
20 <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
21 integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
22 crossorigin="anonymous"></script>
23 <script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js"
24 integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
25 crossorigin="anonymous"></script>
26
27 <style>
28 .bd-placeholder-img {
29 font-size: 1.125rem;
30 text-anchor: middle;
31 -webkit-user-select: none;
32 -moz-user-select: none;
base.html
{% load static %}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v4.1.1">
<title>My Project App</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.5/examples/album/">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"
integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV"
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.1/dist/umd/popper.min.js"
integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN"
crossorigin="anonymous"></script>
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<!-- Custom styles for this template -->
<link rel="stylesheet" href="{% static 'app/album.css' %}" type="text/css">
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="/admin/">Admininstration</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="{% url 'index' %}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'tasks' %}">To-Do</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Meeting Minutes</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Reflectives</a>
</li>
</ul>
<form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
</header>
<main role="main" class="container">
<div class="row">
<div class="col-md-12">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% block content %}
{% endblock %}
</div>
</div>
</main>
<footer class="text-muted">
<div class="container">
<p class="float-right">
Back to top
</p>
<p>This is a Bootstrap Album example, reconfigured to suit my project. </p>
<p>New to Bootstrap? Visit the homepage or read our getting started guide.</p>
</div>
</footer>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script src="../assets/js/vendor/jquery.slim.min.js"><\/script>')</script>
<script src="../assets/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
I would appreciate any assistance with this. Thank you in advance
in your allTasks.html you use {% url 'task-detail' task.id %}
but you don't have task object.
Earlier you define loop - {% for i in obj %}, so your url should be {% url 'task-detail' i.id %}