The Django book, for example, clearly states that the admin is for
administrators. Nothing less.
- Ludvig
Says you.
Admin is for admins. Not limited users.
Write your own views.
--
Collin Grady
Admin is for admins. Not limited users.
To get back to the original question, you can do this right now with a
bit of custom admin code. Take a look at
``ModelAdmin.has_change_permission`` -- you can override this method
to control exactly what the definition of "can change" is for a
particular object. Since this object gets passed ``request``, you can
differentiate between changelist requests and object change requests.
Alternately, your ``ModelAdmin`` subclass can extend the
``change_view`` or ``changelist_view`` methods directly and influence
their behavior.
gert, if you've got a specific suggestion for a hook to add to
``ModelAdmin`` to make this kind of use easier feel free to float it.
But please first try it my way and let me know why what's already
there won't work.
Jacob
To get back to the original question, you can do this right now with a
bit of custom admin code. Take a look at
``ModelAdmin.has_change_permission`` -- you can override this method
to control exactly what the definition of "can change" is for a
particular object. Since this object gets passed ``request``, you can
differentiate between changelist requests and object change requests.
Alternately, your ``ModelAdmin`` subclass can extend the
``change_view`` or ``changelist_view`` methods directly and influence
their behavior.
If you think about this a bit you'll realize why this is a very, very
bad idea. I can think of at least three reasons.
> i solved this, as you said, by using a ModelAdmin subclass, and from what i
> have seen and done so
> far it looks like all fancy permissin stuff i can think of can be done
> nicely this way, witch is great.
Good to hear. The admin should *not* be complicated by default, but it
*should* be possible for you to add your own complexity if you need
it. So suggestions to change the default behavior are likely to be
viewed with skepticism, but suggestions for new hooks are probably
going to be accepted enthusiastically.
> But things like this quickly lead to a situation where you want to use your
> own subclass of ModelAdmin
> on _all_ models in the project (including User, Group, etc.)
I agree that this should be easier. Currently, if you stop using
``admin.autodiscover()`` you can register your own ``ModelAdmin`` for
any of the built-in classes (since the defaults won't get loaded).
However, this means you have re-invent admin class discovery, which is
sorta a pain.
I'd love to see suggestions about how we could make overriding admin
options for external models easier -- got any bright ideas?
Jacob
Really, no, there's not. The fact that you disagree with the design
doesn't mean it's a "design flaw." Put it this way: I drive a very
small car. The fact that it can't hold as much cargo as a pickup truck
isn't a "flaw" -- it's just a different decision. We've decided that
the fundamental action in the admin is changing things and that
add/delete are spin-offs of that. It's not "wrong," just apparently
not what you'd expected. Sorry about that.
> 2) On a non-technical level I absolutely love Django and I would love
> to see it become the "next big thing".
"Just do this one thing and you'll be more popular" didn't end well
for me in high school, and it's not a good technical argument either.
Let's stick to the tech and leave the popularity contest out of it.
Jacob
On Thu, Dec 18, 2008 at 10:35 AM, christian schilling
<init...@googlemail.com> wrote:
> mybe changelist views should not check permissions at all, by default.
If you think about this a bit you'll realize why this is a very, very
bad idea. I can think of at least three reasons.
> i solved this, as you said, by using a ModelAdmin subclass, and from what i
> have seen and done so
> far it looks like all fancy permissin stuff i can think of can be done
> nicely this way, witch is great.
Good to hear. The admin should *not* be complicated by default, but it
*should* be possible for you to add your own complexity if you need
it. So suggestions to change the default behavior are likely to be
viewed with skepticism, but suggestions for new hooks are probably
going to be accepted enthusiastically.
I agree that this should be easier. Currently, if you stop using
> But things like this quickly lead to a situation where you want to use your
> own subclass of ModelAdmin
> on _all_ models in the project (including User, Group, etc.)
``admin.autodiscover()`` you can register your own ``ModelAdmin`` for
any of the built-in classes (since the defaults won't get loaded).
However, this means you have re-invent admin class discovery, which is
sorta a pain.
I'd love to see suggestions about how we could make overriding admin
options for external models easier -- got any bright ideas?
Jacob, I understand your position very well.
You want to keep admin simple and easy for users to use and understand.
Adding "view" permission and maybe some other permissions is a typical
task if you want to customize admin interface. Right now most of
novice python and django developers can't do this properly.
Let's make this task simple, like you made changing objects simple with admin.
Writing documentation on how to make this, or adding this to django, whatever.
This is the first "request" from us "customizators".
Of course, you don't have to make this task simple yourself -- but
then please point us what we should do to make this easy with django.
Second is "readonly" data problem in admin.
It's also typical task on admin customization, and it's not easy for a
novice also.
Third is your point of view to admin customization at all.
I see you and some other people showing us position that admin is not
built for customization in mind, but it's possible to do that.
I have different position: let's make that easy.
Current hooks are not going to make that easy. They are workarounds by nature.
The result code is messy after such admin customization (if you need
to add more than one feature, of course).
The best solutions in this domain are not documented in one source.
So, let's think together, how we can make admin customization even
more easy that is now?
I'm also interested if you have a lot of experience customizing admin
interface in your recent projects. Was that hard? Was the code a mess
after that?
P.S. Other typical requests I implemented in different projects and
didn't feel it was easy either:
* Attribute change history,
* Unified non-admin changes history in admin interface,
* Readonly widgets.
* Multi-stage add (like you did on user add)
* Inline objects in add stage.
* New permissions like "Changeable by creators only", "Changeable if
assigned to user".
* Different types of fields visible to different users in change page.
Sometimes I thinking maybe it was faster to write my own site
administration framework instead of customizing existing one... But a
thought that admin interface is already written, is powerful and is so
simple to begin with, always stopped me from this.
my use case was for DjangoCon Europe where admins were allowed to see ticket info, but only "super admins" were allowed to change them as changes likely had an impact on payments etc too (read PayPal). The solution was that everyone had change/add permission, only super admins had delete perms. Further I changed get_readonly_fields to mark everything read-only for non-super admins. That was perfectly doable but was needlessly complicated in my opinion.
it could be solved in a third party app but I'd argue having this option by default would be beneficial to lots of users.
just my two cents...
Jonas