Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML Django Basics Django Templates Add a Detail View

Y B
Y B
14,136 Points

Use related name instead of _set()

When we set up a Foreign Key field in our models we can assign it a related name. From what I understand we can use this instead of object_set(). Is this what you would recommend for best practice?

1 Answer

It's there for you to use, if you feel it would make more sense. I think it's important to know what Django sets as the default though.

You'd also want to make sure you're consistent in your naming scheme so it doesn't get all jumbled up later.

Very helpful, can you explain how related name works?

Naivedya Bansal
Naivedya Bansal
2,936 Points

Step becomes "step" in step_set(). Is this django convention? What is the model name was lower case to begin with?