Skip to content
Advertisement

Accessing a parent model attribute within Django template

I have an app that has a list of projects, and each project has a number of posts, and when you click on a project, it shows all of the posts in that project, but I can’t figure out how to make it display what project the user is currently on, sample of it not working It should say “Posts for project 1” for example. Here is the relevant code of what I have so far.

JavaScript
JavaScript
JavaScript
JavaScript

Apologies if some of that code wasn’t needed, I am new to Django.

Advertisement

Answer

I figured it out by making the model of “ProjectPostListView” into a Project, and then changing that to a DetailView so I could just use all of the post objects associated with that project.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement