[Django] #17498: meta option "no_index"

44 views
Skip to first unread message

Django

unread,
Jan 3, 2012, 11:19:45 AM1/3/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+--------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.2
Severity: Normal | Keywords: admin
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------
I have come upon an interesting use case that I believe would benefit from
a new option. I have a model that is normally administered underneath
another model via a TabularInline arrangement. However, this model may
also be a foreign key option to other models. When going to the admin
page of these other models, the normal "+" sign graphic to add a model is
not present (which makes sense, as it is not registered independently with
the admin). However, I need the "+" sign add option to appear, but also
want the object to not appear in the main index by itself -- because it
should be administered via the TabularInline's underneath its normal
parent object and two standard paths to the same object cause user
confusion.

(There is more detail here:
http://groups.google.com/group/django-
users/browse_thread/thread/99f90b66e24cfa60 .)

The patch I propose and attach is against Django version 1.2.5. It adds
an option "no_index" to the models' meta class which causes an
independently registered model to not appear in the main index or app
index. (The patch is functional, but not pretty. If the use case and
feature are deemed valuable, it might be implemented in a better way.
(E.g., it only checks for the presence of "no_index" and ignores the
value.))

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

Django

unread,
Jan 3, 2012, 1:47:00 PM1/3/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+--------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.2
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by kace):

* needs_docs: => 0
* needs_tests: => 0
* needs_better_patch: => 1


Comment:

As regards solutions, let me add that the place I was looking and hoping
for a solution was as an option to the "admin.site.register()" function.
With something like "admin.site.register(kids, no_index=True)", for
example. That would be much more appropriate since it's an admin issue,
not a model issue. I just didn't have time to pursue an ideal solution.
Thanks.

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

Django

unread,
Jan 5, 2012, 2:51:46 PM1/5/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+--------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: 1.2
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by kace):

* needs_better_patch: 1 => 0


Comment:

I just attached a new patch that implements in a cleaner way. Only
touches "django/contrib/admin/sites.py" and
"django/contrib/admin/options.py" and changes/adds three lines of code.
Could be easily ported to other versions I think. To suppress indexing,
one adds the option "no_index=True" to the "admin.site.register" function
(as proposed in previous comment).

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:2>

Django

unread,
Feb 10, 2012, 7:21:32 AM2/10/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by jezdez):

* needs_better_patch: 0 => 1
* version: 1.2 =>
* needs_tests: 0 => 1
* needs_docs: 0 => 1
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:3>

Django

unread,
Jun 3, 2012, 10:36:15 PM6/3/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by anonymous):

I created docs and tests for this, and made it so no_index would also
exclude it's ModelAdmin from the app-level index as well.

Here is the pull request: https://github.com/django/django/pull/107/files

Please let me know if I did the tests wrong or something.

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:4>

Django

unread,
Jun 3, 2012, 10:36:29 PM6/3/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by anonymous):

* needs_better_patch: 1 => 0

* needs_tests: 1 => 0
* needs_docs: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:5>

Django

unread,
Jun 3, 2012, 11:50:36 PM6/3/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by charettes):

* cc: charette.s@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:6>

Django

unread,
Jun 4, 2012, 1:09:11 PM6/4/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by samuraiblog@…):

* cc: samuraiblog@… (added)


Comment:

Replying to [comment:4 anonymous]:

> I created docs and tests for this, and made it so no_index would also
exclude it's ModelAdmin from the app-level index as well.
>
> Here is the pull request:
https://github.com/django/django/pull/107/files
>
> Please let me know if I did the tests wrong or something.

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:7>

Django

unread,
Jun 9, 2012, 5:37:50 PM6/9/12
to django-...@googlegroups.com
#17498: meta option "no_index"
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by julien):

* needs_better_patch: 0 => 1

* easy: 1 => 0


Comment:

Thank you all for your work on this ticket.

While I understand and appreciate the need for excluding certain models
from the general index and app indexes, I'm not sold on the suggested
approach. The long-term goal for the admin is to provide more flexibility
around the admin's structure and workflows, and adding a 'no_index' option
would tie `ModelAdmin` to the idea that an index would systematically be
part of the structure.

On this basis, I'm going to reject the current pull request.

The index functionality is currently already tied to
`contrib.admin.sites.AdminSite`. It should already be possible to exclude
models from the index by overriding the `index()` and `app_index()`
methods, although I admit it probably wouldn't be pretty. A new API could
be designed to make it prettier and easier, but I believe that should be
done in `AdminSite`, not `ModelAdmin`.

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:8>

Django

unread,
May 7, 2016, 6:34:18 PM5/7/16
to django-...@googlegroups.com
#17498: Add a way to register a model with the admin but prevent it from appearing
on the app index page
-------------------------------+------------------------------------

Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:9>

Django

unread,
May 8, 2016, 8:40:58 PM5/8/16
to django-...@googlegroups.com
#17498: Add a way to register a model with the admin but prevent it from appearing
on the app index page
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by charettes):

* cc: charette.s@… (removed)


--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:10>

Django

unread,
May 16, 2016, 8:07:27 PM5/16/16
to django-...@googlegroups.com
#17498: Add a way to register a model with the admin but prevent it from appearing
on the app index page
-------------------------------+------------------------------------
Reporter: kace | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by collinanderson):

I personally use this workaround, but it's undocumented:

{{{
def get_model_perms(self, request):
return {}
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:11>

Django

unread,
Sep 25, 2017, 1:41:15 PM9/25/17
to django-...@googlegroups.com
#17498: Add a way to register a model with the admin but prevent it from appearing
on the app index page
-------------------------------+------------------------------------
Reporter: kace | Owner: heba1108
Type: New feature | Status: assigned

Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by heba1108):

* status: new => assigned
* owner: nobody => heba1108


--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:12>

Django

unread,
Feb 6, 2021, 2:21:00 PM2/6/21
to django-...@googlegroups.com
#17498: Add a way to register a model with the admin but prevent it from appearing
on the app index page
-------------------------------+------------------------------------
Reporter: kace | Owner: (none)

Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Mariusz Felisiak):

* owner: heba1108 => (none)
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:13>

Django

unread,
Feb 6, 2021, 3:54:17 PM2/6/21
to django-...@googlegroups.com
#17498: Add a way to register a model with the admin but prevent it from appearing
on the app index page
-------------------------------+------------------------------------
Reporter: kace | Owner: (none)
Type: New feature | Status: new
Component: contrib.admin | Version:
Severity: Normal | Resolution:
Keywords: admin | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by Tim McCurrach):

This is already solved by `has_module_permission`. From the docs:

"Should return True if displaying the module on the admin index page and
accessing the module’s index page is permitted, False otherwise. Uses
User.has_module_perms() by default. Overriding it does not restrict access
to the view, add, change, or delete views..."

Unless there's something I'm missing, this ticket can be closed.

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:14>

Django

unread,
Feb 7, 2021, 11:30:25 PM2/7/21
to django-...@googlegroups.com
#17498: Add a way to register a model with the admin but prevent it from appearing
on the app index page
-------------------------------+-------------------------------------
Reporter: kace | Owner: (none)
Type: New feature | Status: closed
Component: contrib.admin | Version:
Severity: Normal | Resolution: duplicate

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

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


Comment:

Tim thanks for pointing this out. We can close it as a duplicate of #6327.

Fixed in 504c89e8008c557a1e83c45535b549f77a3503b2.

--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:15>

Reply all
Reply to author
Forward
0 new messages