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


reverse and get_absolute_url ?

Can somebody help me understand the reverse and the get_absolute_url please. I really confuse and don't understand. I try to read the document but i still dont get it.

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

The method get_absolute_url() is intended to be defined on a Model so that model.get_absolute_url() will return a URL string that would point to this model's view. This method can be called from a template. See get_absolute_url in the docs.

The reverse() function from django.utils.reverse uses the name attributes in URLs defined by url(_) [before django 2.0] or path() [django 2.0+].

In templates, the url filter can be used in place of reverse() to obtain the URL path based on the name attribute.

Post back if you need more details. Good luck!