Page 404 - No Job matches the given query.

166 views
Skip to first unread message

Kean

unread,
Sep 7, 2019, 3:28:59 PM9/7/19
to Django users
Hi,

New to Django, Have an issue. the table exists and the view references the table however, I still get 404 message.
I have spent 8 hours trying to resolve, nothing seems to work, please help?

urls.py

 path('businesslogin/businessadmin/busproject',
         views.project_detail, name='project_detail'),

models.py

class Job(models.Model):
    name = models.CharField(max_length=100)
    budget = IntegerField()

    def __str__(self):
        return(self.name)


class Category(models.Model):
    project = models.ForeignKey(
        Job, on_delete=models.CASCADE)
    name = models.CharField(max_length=150)

    def __str__(self):
        return(self.project)

class Expense(models.Model):
    project = models.ForeignKey(
        Job, on_delete=models.CASCADE, related_name='expenses')
    title = models.CharField(max_length=100)
    amount = models.DecimalField(max_digits=8, decimal_places=2)
    category = models.ForeignKey(Category, on_delete=models.CASCADE)

    def __str__(self):
        return(self.project)

views.py

def project_detail(request):
    project = get_object_or_404(Job)
    return render(request, 'projectdetail.html', {'project': project, 'expense_list': project.expenses.all()})


Error message:

Page not found (404)

Request Method:GET
Request URL:http://127.0.0.1:8000/businesslogin/businessadmin/busproject
Raised by:core.views.project_detail

No Job matches the given query.




Please can anyone help, with getting the url to connect and resolving this error?


Best 


Kean

Mclaren Sunday

unread,
Sep 7, 2019, 6:58:52 PM9/7/19
to django...@googlegroups.com
What are you trying to do?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0c13a01b-ff4f-4c59-9f9c-d8805b1d2ef8%40googlegroups.com.

Kean

unread,
Sep 8, 2019, 6:55:04 AM9/8/19
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages