Hi I am just getting started with Django but for some reason I am getting this error over and over again. It’s probably something related to the owner in projects.html, because if i click on the link I get the error message from the title. Thanks for your help.
projects/models.py
class Project(models.Model):
owner = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.SET_NULL)
title = models.CharField(max_length=200)
users/models.py
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE, null=True, blank=True)
name = models.CharField(max_length=200, blank=True, null=True)
Side note: When posting blocks of code (or templates) here, surround the block between lines of three backtick - ` characters. That 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, and prevents it from trying to iterpret or filter lines. (The backtick lines must be lines on their own, before and after each block.)
You show the projects.html template, but you don’t show the view that is supposed to render that template. It’s that view we need to see, not the userProfile view.
Generally speaking, that error comes from the url tag needing a parameter not being supplied. For some reason, at that point in the template, project.owner.name doesn’t return a value. Usually, what I see around here for that situation is that the context isn’t created correctly.
That´s a part of the Project model. So yeah blank=True
class Project(models.Model):
owner = models.ForeignKey(Profile, null=True, blank=True, on_delete=models.SET_NULL)
The template should render out some basic informations about the user
I don´t know if I got that right but after the url ‘user-profile’ I typed the project.owner.name in to navigate to the specific site of the user who created this project