On Mar 6, 12:42 pm, David Reynolds <[EMAIL PROTECTED]>
wrote:
> On 5 Mar 2008, at 6:17 pm, Josh Ourisman wrote:
>
> > There are two ways in which I want to customize the admin interface
> > for a project I'm working on. As far as I can tell, these sorts of
> > customizations aren't built in, but before I start trying to write
> > them myself I just want to make sure I'm not reinventing the wheel
> > here. So, the two things I want to do are as follows:
>
> > 1. This is a multi-site project, so most models have a site field. One
> > particular model, locations, has a site field as well as a many-to-
> > many relationship with the neighborhood model which also has a site
> > field. What I want is that when editing a location object the
> > neighborhoods that show up in the select box are only those
> > neighborhoods that are related to the same site as the location being
> > edited.
>
> > 2. The location model also has a URL field which is non-required. I
> > would like, when listing the locations in the admin interface, to be
> > able to filter the view based on whether or not the location has a
> > URL. Currently, if I just add that field as a filter it lists every
> > single value of that field which isn't what I want (as there are
> > several hundred values).
>
> > Is there some easy built-in way to do either or both of these things
> > that I'm just not aware of?
>
> As you say, in trunk currently there is no real way of doing this. I
> suggest you take a lot at the newforms-admin trunk and see if you are
> able to do these kinds of modifications using that.
It looks as though there are no hooks for handling the filter lists in
newforms-admin so you'll need to override the changelist_view in your
ModelAdmin class and most likely create your own FilterSpec subclass
for the site, neighbourhood and URL fields. You could also cheat and
just add in some links on the page which apply appropriate filters in
the GET variables (Fields don't have to be in 'list_filter' for
filtering to work).
For 1 I think that you can most probably do something by creating a
custom manager, but this isn't something that I've played with, so
cannot offer any more help.
Regards,
Felix
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---