On 11/7/06, Florian Apolloner <[EMAIL PROTECTED]> wrote:
> 1.) In the admin-area you can use filters ( list_filter = ('is_staff',
> 'is_superuser') ), which show by default all entries. Now I want to
> have the entries prefilterd (let's say i have a boolean field, and want
> all entries with true filtered out).
> Which way is the easiest way to do so?

list_filter should produce a list of links in the sidebar you can
click on to filter according to the values of the field; for example;
using 'is_staff' in list_filter for the auth.User model lets you click
to see either all users who are staff, or all users who aren't.


> 2.) Is there a hook or something to execute custom functions, if
> someone clicks save in the admin area?

For custom save functionality, your model class can supply a custom
'save' method which executes anything you like; the documentation has
some simple examples:
http://www.djangoproject.com/documentation/model_api/#overriding-default-model-methods

> 3.) Lets assume I have a model with an integerfield position. In the
> admin-area I would like to be able to set this field to something, that
> would get me two arrows (up and down) to change place with the next
> item. Is there a way to do so? (Like a navigation-admin where I want to
> get 'Home' from bottom to top, or 'contact' after 'Forum' and not
> before it....)

There's nothing built in to Django which does this, and building it
into the admin would probably involve quite a bit of work. Writing
your own custom view which handles it probably wouldn't be too hard,
though. The biggest problem you'll run into is that performance will
be bad -- to do this, every save of an instance of the model will have
to SELECT all instances of that model and run UPDATE against a
potentially large number of them.

If you want to set that up, though, a manager method is probably the
best way to go (e.g., a method on the model's manager class which
takes an instance and a new value for its "order", and then works out
which other instances need to change).

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

--~--~---------~--~----~------------~-------~--~----~
 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to