--
Ticket URL: <https://code.djangoproject.com/ticket/17498>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* 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>
* 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>
* 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>
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>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:5>
* cc: charette.s@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:6>
* 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>
* 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>
--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:9>
* cc: charette.s@… (removed)
--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:10>
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>
* status: new => assigned
* owner: nobody => heba1108
--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:12>
* owner: heba1108 => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/17498#comment:13>
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>
* 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>