Ok, either I missed this earlier or this was an edit:
project_name = models.ForeignKey(Project, to_field='project_name', on_delete=models.CASCADE)
You’ve got the “to_field” defined in your foreign key definition, but you’re passing the integer value in as the parameter.
You need to do one of the following:
-
Pass in the project name as the url parameter
-
Rewrite your query to work with the non FK id
-
(Recommended) Eliminate the “to_field” attribute of your ForeignKey specification. Yes, that attribute has some value - but this really isn’t one of those cases. You’re only going to make things more difficult for yourself by doing it the way you have it now.