get_absolute_url for topic and posts
See original GitHub issueWhen I send notification to a poster and I would like to include a link to the post itself. However, there is no get_absolute_url
defined for the Topic
or Post
models. Is there any reason they are not defined?
looks like a good url for Topic
, but there is no similar view_post
url.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Django Quick Tips: get_absolute_url() - Level Up Coding
Create a basic Post model with two properties a title and content . models.py. Views. Then add basic view functions, one responsible for ......
Read more >python - django get_absolute_url on search result
I am trying to insert link to each result so that the user can click a link to that post directly. I think...
Read more >Try Django 1.9 - 19 of 38 - URL Links & Get Absolute URL
Subscribe to our channel: http://bit.ly/1kxmkzq Generally the topics will include: - Django Project Setup - Class Based Views (& some ...
Read more >resource.getAbsoluteUrl() problem - SAP Community
#1.5#0012BF1423AB00450000028E0000144400043198E1852F02#1180432595640#com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl#sap.com/tcwddispwda#com.sap.
Read more >get absolute url for the Image url - MSDN - Microsoft
Hi akpaga22,. Thanks for your post. I guess that your image path is a local file path and not a Url,so you cann't...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, I think I explicitly stated in my previous message why it was removed: to improve separation of concern. 🙂 There is no need to debate whether or not having this method defined in models is a good or bad practice in general: I already stated that I was open to see it reintroduced.
https://github.com/ellmetha/django-machina/commit/905f23a1f2a4eb64b282191778522fd83f9ca7d7 might not apply cleanly but all needed changes appear to be there.
I really do not understand why
get_absolute_url()
was removed because it provides a natural Django way to refer to the forum, topic, or post without the longreverse(slug, pk, slug, pk)
calls. Yes it means “presentation-related things in model”, it means server side rendering and might not work well with RESTful or SPA, but as a Django app it is natural to provide them and leave it to users on how to use them (andABSOLUTE_URL_OVERRIDES
is one way to override it).I have added these to my extended
Topic
class and might submit a PR when I get some time. Addingget_absolute_url
is trivial but it takes more time to use it consistently throughout the project.