[Django] #35076: improvement to the doc of ModelAdmin.view_on_site

25 views
Skip to first unread message

Django

unread,
Dec 31, 2023, 8:24:09 AM12/31/23
to django-...@googlegroups.com
#35076: improvement to the doc of ModelAdmin.view_on_site
------------------------------------------------+------------------------
Reporter: redstoneleo | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Whether get_absolute_url() is defined determines the visible state of the
“View on site” button, I suggest to change [the
doc](https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.view_on_site)
to the following to emphasize this(Note I have read the official doc on
contributing to the doc, but it is hard for me to do that, so I posted my
suggestion here ).


If the object’s
[`get_absolute_url()`](https://docs.djangoproject.com/en/4.2/ref/models/instances/#django.db.models.Model.get_absolute_url
"django.db.models.Model.get_absolute_url") method is defined, then set
`view_on_site` to control whether or not to display the “View on site”
link. This link should bring you to a URL where you can display the saved
object. Otherwise, no effect.

This value can be either a boolean flag or a callable. If `True` (the
default), the object’s
[`get_absolute_url()`](https://docs.djangoproject.com/en/4.2/ref/models/instances/#django.db.models.Model.get_absolute_url
"django.db.models.Model.get_absolute_url") method will be used to
generate the url.

--
Ticket URL: <https://code.djangoproject.com/ticket/35076>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 31, 2023, 9:41:32 AM12/31/23
to django-...@googlegroups.com
#35076: improvement to the doc of ModelAdmin.view_on_site
-------------------------------------+-------------------------------------
Reporter: redstoneleo | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 4.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Old description:

> Whether get_absolute_url() is defined determines the visible state of
> the “View on site” button, I suggest to change [the
> doc](https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.view_on_site)
> to the following to emphasize this(Note I have read the official doc on
> contributing to the doc, but it is hard for me to do that, so I posted my
> suggestion here ).
>

> If the object’s
> [`get_absolute_url()`](https://docs.djangoproject.com/en/4.2/ref/models/instances/#django.db.models.Model.get_absolute_url
> "django.db.models.Model.get_absolute_url") method is defined, then set
> `view_on_site` to control whether or not to display the “View on site”
> link. This link should bring you to a URL where you can display the saved
> object. Otherwise, no effect.
>
> This value can be either a boolean flag or a callable. If `True` (the
> default), the object’s
> [`get_absolute_url()`](https://docs.djangoproject.com/en/4.2/ref/models/instances/#django.db.models.Model.get_absolute_url
> "django.db.models.Model.get_absolute_url") method will be used to
> generate the url.

New description:

Whether get_absolute_url() is defined determines the visible state of the
“View on site” button, I suggest to change

[https://docs.djangoproject.com/en/4.2/ref/contrib/admin/#django.contrib.admin.ModelAdmin.view_on_site
the doc] to the following to emphasize this(Note I have read the official


doc on contributing to the doc, but it is hard for me to do that, so I
posted my suggestion here ).


If the object’s
[https://docs.djangoproject.com/en/4.2/ref/models/instances/#django.db.models.Model.get_absolute_url
"django.db.models.Model.get_absolute_url" get_absolute_url()] method is


defined, then set `view_on_site` to control whether or not to display
the “View on site” link. This link should bring you to a URL where you can
display the saved object. Otherwise, no effect.

This value can be either a boolean flag or a callable. If `True` (the
default), the object’s

[https://docs.djangoproject.com/en/4.2/ref/models/instances/#django.db.models.Model.get_absolute_url
get_absolute_url()]("django.db.models.Model.get_absolute_url") method


will be used to generate the url.

--

Comment:

Thanks for the ticket, however, the current wording is clear enough (IMO).

> If `True` (the default), the object’s `get_absolute_url()` method will


be used to generate the url.

It clearly indicates that it won't do anything if you model doesn't have a
`get_absolute_url()`. It's also followed by a sentence when it's
explicitly stated:

> **If your model has a** get_absolute_url() method but you don’t want the
“View on site” button to appear, you only need to set view_on_site to
False:

--
Ticket URL: <https://code.djangoproject.com/ticket/35076#comment:1>

Reply all
Reply to author
Forward
0 new messages