> e.g, when I´m using djangos auth-app and I´m extending the user-model
> with a user-profile, I´m having "auth" (with users and groups) and
> "user" (with user profile) on my admin index page. orderd by names,
> auth is very much on the top of my page while user is at the bottom.
> for an editor, this is probably hard to understand (because the editor
> doesn´t know anything about apps). for an editor, it´d more
> comfortable having a headline "user management" with the apps "users",
> "groups" and "user profiles". this re-arrangement could be defined in
> admin.py.
You can also define the arrangement by overriding the admin template for the
index and hard coding in your own order. It's not ideal, but it's perhaps
preferable to adding another place for configuring the admin. If you want
this kind of flexibility for the index page, you might also want to add extra
notes etc onto the page, which makes customising the template a reasonably
good way to do it.
Having an admin.py for every project is a bit vague, because 'projects' don't
really exist as far as Django is concerned, only 'apps'.
Luke
--
I teleported home one night
With Ron and Sid and Meg,
Ron stole Meggie's heart away
And I got Sidney's leg
(THHGTTG)
Luke Plant || http://lukeplant.me.uk/
It depends :-)
It is a slight problem in that we currently require no project-level
code. Everything besides settings and the top-level URLconf is stored
in an application. The admin app is "just another app" - there's
nothing specifically "project level" about it. All the current admin
registrations, for instance, occur with app-level admin.py files, and
you can get very creative about those files.
If you can come up with a compelling reason why a top-level admin.py
file is required, we're happy to listen to it.
> a bit of background information: while using djangos admin-interface
> for about 3 years now, customers always complain about not finding
> stuff on the admin index page. for a bigger website with about 50 apps
> you get a really long list. and I just thought it would be easier if
> apps are combined within sections (again, don´t nail me down on the
> terms ...).
On the face of it, having more ability to customize is always going to
be good. The problem is, we need specificity here. So far, all we know
about your proposal is that it involves a project-level admin.py. What
will be in that file? How will it integrate with the AdminSite? With
ModelAdmins? A project-level admin.py file isn't inherently wrong
(although I must say I do share Luke's aversion to such a suggestion).
However, it really depends on what you intend to put into that file.
If you give some concrete suggestions, we can give some concrete
feedback. Making suggestions with an eye to potential implementation
difficulties (i.e., can we actually push admin to do this?) will gain
bonus points.
Yours,
Russ Magee %-)
Well, for starters, some clarification would help.
Are we talking about an alternate organization for models in the admin
so you're not bound to app-based categories, or are we talking about
some higher level organization?
Your example puts django.contrib.auth into the 'User Management'
collection - is that indicating that all the apps in auth should be
shown in "User Management", or that there is a "User Management"
super-group that contains the auth group that contains the auth
applications?
Your language is particularly confusing in this regard - it isn't
clear when you say 'apps' if you actually mean 'models'.
Secondly, why would this be included in settings.py (or a top level
admin.py for that matter)? Admin registrations are currently
distributed across the apps in the entire project - why is there a
need to pull this into a single location?
Couldn't this be achieved by registering a model with a particular
"app collection" (with the default being the collection formed by the
app containing the model)?
i.e., to create a "User Management" group, and put "user" in it:
class UserManagement(AdminGroup):
label = "UserManagement"
class UserAdmin(ModelAdmin):
...
class UserAdmin(ModelAdmin):
...
admin.site.register(User, UserAdmin, group=UserManagement)
Yours,
Russ Magee %-)
Since this all seems to be specific to particular instances of
AdminSite, AdminSite would be the logical place to do it if it's going
to get code-level support. However...
> 2. Some ability to regroup and choose better names is a biggie. It
> pains me when I try and explain to my admins what 'auth' means...
Practically everything being requested here is purely presentational.
And Django has a component for doing presentational logic: the
template system. The admin templates are deliberately easy to override
with custom versions, and it feels like all of this is really just
asking for things that are more cleanly done in templates.
We (World Online) do this rather frequently, including shuffling
things around, re-labeling bits, showing extra links to custom things
we've added to particular applications. And we do it entirely in
templates; it's not particularly hard.
--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."
This isn't completely true - at least, not if you want to affect the
URL structure as well. If you're just looking be able to use:
/admin/<app>/<model>
and replace that with:
/admin/<app group>/<model>
then you need some form of representation at the code level. This
can't be done purely with templates.
This distinction is really only important if you want the URL
structure to reflect of logical structure, rather than code structure
(which, broadly speaking, is a good thing to be doing from the "URL as
interface" argument). However, this use case could be handled at
present with a custom site that overrides get_urls to provide the
'group' landing page, etc.
I can see that providing a DSL-style way to set up these groups could
be handy for a small group of users, but I can't say it's a
particularly compelling use case for me personally.
I strongly suspect that this could (and therefore, should) be handled
as an external project in the initial phases - i.e., a
"django-extended-admin' project that provides the AdminSite and
ModelAdmin extensions that would make a DSL-for-groups approach
possible. Patrick, Joshua - if you're enthused about this idea, I
suggest you combine your efforts and try to make this external project
a reality. If this external project gains traction, then we can look
at merging it back to trunk.
Yours,
Russ Magee %-)