List Info

Thread: Django admin: Is this possible with 'list_filter'??




Django admin: Is this possible with 'list_filter'??
user name
2007-12-17 21:45:42
Hello,

I have a question about the use of 'list_filter' in the
Django admin:

Is it possible to filter a list of records ('Chapters') of
model 'B'
by a field ('language') of model 'A' (to which a ForeignKey
field in
model 'B' is referring)?

For example:
------------------------------------------------------------
-------
#model 'B'
class Book(models.Model):
    title = models.CharField(max_length=100)
    author = models.CharField(max_length=100)
    language = models.CharField(max_length=30)  # <<
filter

# model 'B'
class Chapter(models.Model):
    title = models.CharField(max_length=100)
    book = models.ForeignKey(Book)
------------------------------------------------------------
-------

Overriding default manager 'objects' seems too rigid, since
all
records must be listed when I desire so.

I gave the issue a very slow thought just ago and I
wondered: Wouldn't
it be nice if you could specify dedicated managers to be
used for a
certain 'list_filter'?

You could then attach an advanced (or not so advanced)
manager to each
filter criterion.

Like:
------------------------------------------------------------
-------
list_filter = (
    ('language', {
        'english': ('objects_en',),
        'french': ('objects_fr',)
    }),
)
------------------------------------------------------------
-------

Would this make any sense at all?

Maybe newforms-admin already provides hooks for similar
functionality.

My initial question and the subsequent proposal diverge a
bit. Any
help or comments on either are greatly appreciated. Really!

So long,
Weather
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Django admin: Is this possible with 'list_filter'??
user name
2007-12-17 21:55:44
Seems someone has already given this way better thought than
I did.
See: "newforms-admin enable registering custom
FilterSpecs" [1]

Very interesting indeed.

[1] http://code
.djangoproject.com/ticket/5833


On Dec 18, 4:45 am, weathermess <weatherm...googlemail.com> wrote:
> Hello,
>
> I have a question about the use of 'list_filter' in the
Django admin:
>
> Is it possible to filter a list of records ('Chapters')
of model 'B'
> by a field ('language') of model 'A' (to which a
ForeignKey field in
> model 'B' is referring)?
>
> For example:
>
------------------------------------------------------------
-------
> #model 'B'
> class Book(models.Model):
>     title = models.CharField(max_length=100)
>     author = models.CharField(max_length=100)
>     language = models.CharField(max_length=30)  #
<< filter
>
> # model 'B'
> class Chapter(models.Model):
>     title = models.CharField(max_length=100)
>     book = models.ForeignKey(Book)
>
------------------------------------------------------------
-------
>
> Overriding default manager 'objects' seems too rigid,
since all
> records must be listed when I desire so.
>
> I gave the issue a very slow thought just ago and I
wondered: Wouldn't
> it be nice if you could specify dedicated managers to
be used for a
> certain 'list_filter'?
>
> You could then attach an advanced (or not so advanced)
manager to each
> filter criterion.
>
> Like:
>
------------------------------------------------------------
-------
> list_filter = (
>     ('language', {
>         'english': ('objects_en',),
>         'french': ('objects_fr',)
>     }),
> )
>
------------------------------------------------------------
-------
>
> Would this make any sense at all?
>
> Maybe newforms-admin already provides hooks for similar
functionality.
>
> My initial question and the subsequent proposal diverge
a bit. Any
> help or comments on either are greatly appreciated.
Really!
>
> So long,
> Weather
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )