[Django Code] #3400: [patch] Support for lookup separator with list_filter admin option

4 views
Skip to first unread message

Django Code

unread,
Jan 30, 2007, 12:59:29 AM1/30/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-----------------------------+----------------------------------------------
Reporter: ni...@intv.com.au | Owner: adrian
Status: new | Component: Admin interface
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 1
-----------------------------+----------------------------------------------
This patch adds support for using the lookup separator in the list_filter
option, for example:

{{{
class Town(models.Model):
name = models.CharField()

class House(models.Model):
town = models.ForeignKey(Town)

class Room(models.Model):
house = models.ForeignKey(House)

class Booking(models.Model):
room = models.ForeignKey(Room, raw_id_admin=True)

class Admin:
list_filter = ('room__house__town',)
}}}

Will add a filter "For town:" that spans multiple foreign keys.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines

Django Code

unread,
Jan 30, 2007, 3:43:42 AM1/30/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
--------------------------------+-------------------------------------------
Reporter: ni...@intv.com.au | Owner: adrian
Status: new | Component: Admin interface
Version: SVN | Resolution:
Keywords: list_filter | Stage: Design decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
--------------------------------+-------------------------------------------
Changes (by Simon G. <d...@simon.net.nz>):

* keywords: => list_filter
* needs_better_patch: => 0
* stage: Unreviewed => Design decision needed
* needs_tests: => 0
* needs_docs: => 0

Comment:



--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:1>

Django Code

unread,
Jan 31, 2007, 1:29:02 AM1/31/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
--------------------------------+-------------------------------------------
Reporter: ni...@intv.com.au | Owner: adrian
Status: new | Component: Admin interface
Version: SVN | Resolution:
Keywords: list_filter | Stage: Design decision needed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
--------------------------------+-------------------------------------------
Comment (by ni...@intv.com.au):

Hmm not sure how I didn't notice before, but this breaks the model
validation in django.core.management:

{{{
for fn in opts.admin.list_display:
try:
f = opts.get_field(fn)
except models.FieldDoesNotExist:
if not hasattr(cls, fn):
e.add(opts, '"admin.list_display" refers to %r, which isn\'t
an attribute, method or property.' % fn)
else:
if isinstance(f, models.ManyToManyField):
e.add(opts, '"admin.list_display" doesn\'t support
ManyToManyFields (%r).' % fn)
}}}

Of course, it shouldn't be hard to fix - but is it worth it? This type of
filtering is very useful for my particular apps but if it's not considered
common enough for the core there's no point fixing the validation.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:2>

Django Code

unread,
Feb 10, 2007, 5:01:57 AM2/10/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
--------------------------------+-------------------------------------------
Reporter: ni...@intv.com.au | Owner: adrian
Status: new | Component: Admin interface
Version: SVN | Resolution:
Keywords: list_filter | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
--------------------------------+-------------------------------------------
Changes (by mtredinnick):

* needs_better_patch: 0 => 1
* stage: Design decision needed => Accepted

Comment:

I think it's worth getting this right. You probably aren't the only person
wanting this functionality.

A couple of comments on the patch:

1. please create the diff from the top of the Django source tree. I had
to guess a lot to work out that it was to be applied to
{{{django/contrib/admin/views/main.py}}} (which I think is right). Having
the full path from the tree root to the patched file is helpful.
2. If the {{{FakeForeignKey}}} class has any visibility outside of that
function (which I'm not sure about), it shouldn't be declared inside the
function. In fact, I'm not really thrilled with declaring it inside the
function in the first place, so probably best to move it out to the top-
level of the file. I realise you are trying to avoid namespace pollution,
but it's not worth the sacrifice of clarity to me.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:3>

Django Code

unread,
Feb 13, 2007, 6:50:34 PM2/13/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
--------------------------------+-------------------------------------------
Reporter: ni...@intv.com.au | Owner: adrian
Status: new | Component: Admin interface
Version: SVN | Resolution:
Keywords: list_filter | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
--------------------------------+-------------------------------------------
Changes (by nick.l...@gmail.com):

* cc: nick.l...@gmail.com (added)

Comment:

1. Oops, sorry about the diff - yes that's the correct file.
2. {{{FakeForeignKey}}} is a wrapper around the {{{ForeignKey}}} field so
that the {{{RelatedFilterSpec}}} will work across the foreign keys.
Perhaps it could have a better name. It is only instantiated inside
{{{get_filters()}}}, but {{{RelatedFilterSpec}}} will have access to it..
so I'll move it to the top-level of the file like you have suggested.

Will update the patch shortly when I have some time, Cheers.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:4>

Django Code

unread,
Feb 18, 2007, 8:33:23 AM2/18/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
--------------------------------+-------------------------------------------
Reporter: ni...@intv.com.au | Owner: adrian
Status: new | Component: Admin interface
Version: SVN | Resolution:
Keywords: list_filter | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
--------------------------------+-------------------------------------------
Comment (by Simon Litchfield <si...@slicmedia.com>):

Works great thanks Nick. This was bugging me just the other day.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:5>

Django Code

unread,
Mar 1, 2007, 2:17:25 PM3/1/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
--------------------------------+-------------------------------------------
Reporter: ni...@intv.com.au | Owner: adrian
Status: new | Component: Admin interface
Version: SVN | Resolution:
Keywords: list_filter | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
--------------------------------+-------------------------------------------
Comment (by cbr...@redback.com):

This is exactly what I need.
I'm going to apply this and try it out.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:6>

Django Code

unread,
Oct 28, 2007, 11:31:50 AM10/28/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-----------------------------------------------------+----------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: list_filter newforms-admin FilterSpec | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
-----------------------------------------------------+----------------------
Changes (by Honza_Kral):

* keywords: list_filter => list_filter newforms-admin FilterSpec
* version: SVN => newforms-admin

Comment:

I attached an alternative patch for newforms-admin branch... It can deal
with {{{__}}} paths not just for {{{RelatedField}}}s but for any fields.
It will traverse the path, return the last field in the chain and supply
additional parameter {{{field_path}}} that is used for filtering the
results.

With this you can filter for example by a {{{DateField}}} stored on a
related model.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:7>

Django Code

unread,
Dec 1, 2007, 12:25:22 PM12/1/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-----------------------------------------------------+----------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: list_filter newforms-admin FilterSpec | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
-----------------------------------------------------+----------------------
Comment (by Honza_Kral):

Also see #5833 for a way to enable users to register their own filter.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:8>

Django Code

unread,
Mar 19, 2008, 12:57:24 AM3/19/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-----------------------------------------------------------------+----------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: nfa-someday list_filter FilterSpec nfa-changelist | Stage: Accepted
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 1
-----------------------------------------------------------------+----------
Changes (by ales_zoulek):

* keywords: nfa-someday list_filter FilterSpec => nfa-someday
list_filter FilterSpec nfa-changelist

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:10>

Django Code

unread,
Jul 10, 2008, 6:42:56 AM7/10/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
---------------------------------------+------------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: Admin interface | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------+------------------------------------
Changes (by vitek_pliska):

* keywords: nfa-someday list_filter FilterSpec nfa-changelist => nfa-
someday list_filter FilterSpec nfa-changelist
ep2008

Comment:

I checked and applied 3400-against-7875.patch, all tests passed.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:12>

Django Code

unread,
Jul 12, 2008, 10:06:24 AM7/12/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
---------------------------------------+------------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: Admin interface | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------+------------------------------------
Comment (by anonymous):

Just wrote small app for testing this. I don't want to write tests.
models.py:
{{{
from django.conf import settings
from django.db import models
from django.contrib import admin

class Town(models.Model):
name = models.CharField(max_length=64)

def __unicode__(self):
return self.name

class House(models.Model):
town = models.ForeignKey(Town)

def __unicode__(self):
return self.town.name

class Room(models.Model):
house = models.ForeignKey(House)

def __unicode__(self):
return self.house.town.name

class Booking(models.Model):
room = models.ForeignKey(Room)

def __unicode__(self):
return self.room.house.town.name

class BookingOpts(admin.ModelAdmin):
list_filter = ('room__house__town',)
raw_id_admin = ('room', )

admin.site.register(Town)
admin.site.register(House)
admin.site.register(Room)
admin.site.register(Booking, BookingOpts)
}}}
Works fine.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:13>

Django Code

unread,
Aug 7, 2008, 5:20:44 AM8/7/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
---------------------------------------+------------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: Admin interface | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------+------------------------------------
Comment (by anonymous):

I've applied 3400-against-7875.patch to today svn django-trunk and I get
the following error:

Error while importing URLconf 'myapp.urls': `ProjectAdmin.list_filter[8]`
refers to field `technology__programing_languages` that is missing from
model `Project`.

The models are:

class Project(models.Model):
technology = models.ForeignKey("ProjectTechnology",
verbose_name=_('project technology'),unique=True, null=True, blank=True,
editable=False, related_name="technology")
...
class ProjectTechnology(models.Model):
programing_languages = models.ManyToManyField(ProgramingLanguage,
null=True, blank=True)
...
class ProgramingLanguage(models.Model):
name = models.CharField(_('name'), max_length=200)
...

I'm almost a newbie, what it could be?

Thanks.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:14>

Django Code

unread,
Aug 20, 2008, 5:39:46 AM8/20/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
---------------------------------------+------------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: Admin interface | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------+------------------------------------
Comment (by anonymous):

Thanks, 3400-against-8363.patch solves the problem.

Should it be possible now to show attributes (or foreignkeys) of other
model B that have a foreignkey to model A in model A list_filter?, how?

If I should make my question to other sites, don't complaint to tell me.

Thanks in advance.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:15>

Django Code

unread,
Sep 5, 2008, 4:05:14 AM9/5/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
---------------------------------------+------------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: Admin interface | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
---------------------------------------+------------------------------------
Changes (by peritus):

* cc: and...@pelme.se (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:16>

Django

unread,
Oct 27, 2008, 9:02:30 AM10/27/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by anonymous):

Path 3400-against-8363.patch does not run against revision 9285.

Is there a way to use lookup separator without patch django?

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:17>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Nov 1, 2008, 12:11:16 PM11/1/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by cornbread):

Does this patch include a way to add sort_by as well?

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:18>

Django

unread,
Nov 21, 2008, 11:57:54 PM11/21/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by cornbread):

* cc: ric...@cornbread.cc (added)

Comment:

This needs a sort_by option as well:


{{{
class Town(models.Model):
name = models.CharField()

class House(models.Model):
town = models.ForeignKey(Town)

class Room(models.Model):
house = models.ForeignKey(House)

class Booking(models.Model):
room = models.ForeignKey(Room, raw_id_admin=True)

class Admin:
sort_by = ('room__house__town',)

}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:19>

Django

unread,
Nov 22, 2008, 9:07:58 AM11/22/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by HM):

* cc: hann...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:20>

Django

unread,
Nov 25, 2008, 12:50:31 PM11/25/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by jashugan):

* cc: jash...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:21>

Django

unread,
Dec 1, 2008, 5:03:06 PM12/1/08
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by flosch):

* cc: flo...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:22>

Django

unread,
Mar 20, 2009, 6:00:17 AM3/20/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by Almad):

Any improvements needed for this patch?

Is there any chance this can make it in 1.1.?

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:23>

Django

unread,
Mar 31, 2009, 7:30:29 AM3/31/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by mrts):

* milestone: => 1.2

Comment:

Tentatively targeting for 1.2.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:24>

Django

unread,
Apr 2, 2009, 11:18:05 PM4/2/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by gonz):

* cc: gonz (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:25>

Django

unread,
Apr 5, 2009, 7:10:34 PM4/5/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by mrts):

See also #10743.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:26>

Django

unread,
May 7, 2009, 6:39:53 AM5/7/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: nobody
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by jakub_vysoky):

I added patch against newest django trunk version.

main repo lives in http://github.com/HonzaKral/django/tree/ticket3400

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:27>

Django

unread,
May 7, 2009, 7:37:02 AM5/7/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by jakub_vysoky):

* keywords: nfa-someday list_filter FilterSpec nfa-changelist ep2008 =>
edc nfa-someday list_filter FilterSpec nfa-
changelist ep2008
* owner: nobody => jakub_vysoky

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:28>

Django

unread,
Jun 30, 2009, 9:20:08 AM6/30/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by fran...@verbeek.name):

* needs_tests: 0 => 1

Comment:

I feel stupid posting this, but are we sure it works with
related_of_related as in the example above?

Using :


{{{
from django.db import models
class Town(models.Model):
name = models.CharField(max_length=50)

class House(models.Model):
town = models.ForeignKey(Town)

class Room(models.Model):
house = models.ForeignKey(House)

class Booking(models.Model):
room = models.ForeignKey(Room)

}}}


and


{{{
from django.contrib import admin
from content.models import *

class BookingAdmin(admin.ModelAdmin):
list_filter = ('room__house__town',)
pass

admin.site.register(Booking,BookingAdmin)
admin.site.register(Town)
admin.site.register(Room)
admin.site.register(House)
}}}


I get a exception in /django/contrib/admin/views/main.py circa line 85
{{{


if '__' in filter_name:
f = None
model = self.model
path = filter_name.split('__')
for field_name in path[:-1]:
f = model._meta.get_field(field_name)
model = f.rel.to
f = model._meta.get_field(path[-1]) # !!!!
Exception
spec = FilterSpec.create(f, request, self.params,
model, self.model_admin, field_path=filter_name)
else:
f = lookup_opts.get_field(filter_name)
spec = FilterSpec.create(f, request, self.params,
self.model, self.model_admin)
}}}

as it tries to get a field for path[2] (town) on model path[0] (room) on
the first iteration.

I get that problem using the patch 3400-against-9646.patch, which patched
all right against 1.0.2-final. That bit code looks identical on subsequent
patches, though.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:29>

Django

unread,
Jun 30, 2009, 10:22:16 AM6/30/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by fran...@verbeek.name):

solved it by
{{{
for field_name in path[:-1]:
f = model._meta.get_field(field_name)
model = f.rel.to
f =
model._meta.get_field(path[path.index(field_name)+1])
}}}


doesn't look very robust but works so far.. Needs more testing, I guess

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:30>

Django

unread,
Jul 21, 2009, 10:57:16 AM7/21/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by pavelszalbot):

Working and little bit better solution - not creating intermediary
FilterSpec(s):
{{{
for field_index in xrange(len(path)-1):
f = model._meta.get_field(path[field_index])
model = f.rel.to
f = model._meta.get_field(path[field_index+1])
spec = FilterSpec.create(f, request, self.params,
model, self.model_admin, field_path=filter_name)
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:31>

Django

unread,
Aug 17, 2009, 7:16:44 PM8/17/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by aurelio):

* cc: aurelio (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:33>

Django

unread,
Oct 5, 2009, 5:15:36 PM10/5/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by velmont):

* cc: velmont (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:34>

Django

unread,
Oct 6, 2009, 7:31:50 AM10/6/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by andybak):

* cc: an...@andybak.net (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:35>

Django

unread,
Nov 8, 2009, 7:47:17 PM11/8/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by marcob):

* cc: marc...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:36>

Django

unread,
Nov 9, 2009, 6:04:32 PM11/9/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by bendavis78):

Patch currently does not work with reverse relationships. For example:

{{{
#!python
class Target(models.Model):
name = CharField(max_length=200)

class Survey(models.Model):
target = models.OneToOneField(Target)
source = models.ForeignKey(SurveySource)

class TargetAdmin(admin.ModelAdmin):
list_filter = ['survey__source']

}}}

My hunch is that this only breaks in the validation code -- I'm
investigating right now if that will fix it. The only question is how to
correctly traverse reverse relationships using ._meta

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:37>

Django

unread,
Nov 28, 2009, 12:43:33 PM11/28/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: ram...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:38>

Django

unread,
Dec 10, 2009, 6:23:01 AM12/10/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: alexe...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:39>

Django

unread,
Dec 10, 2009, 11:34:27 AM12/10/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by trent):

* cc: tjur...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:40>

Django

unread,
Dec 17, 2009, 4:25:41 AM12/17/09
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by danfairs):

* cc: dan....@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:41>

Django

unread,
Feb 1, 2010, 1:13:37 PM2/1/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: [patch] Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.2
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: sem...@taurinus.org (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:42>

Django

unread,
Feb 18, 2010, 9:55:04 PM2/18/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by SmileyChris):

* summary: [patch] Support for lookup separator with list_filter admin
option => Support for lookup separator with
list_filter admin option
* milestone: 1.2 => 1.3

Comment:

Definitely isn't going to make it into 1.2.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:43>

Django

unread,
Feb 19, 2010, 4:53:55 AM2/19/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by marcob):

@SmileyChris: may We do something to make it into 1.2 ? I'm not lobbying
:-) With something I meaned some real work

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:44>

Django

unread,
Feb 19, 2010, 5:00:40 AM2/19/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by SmileyChris):

No chance. Since 1.2 beta has been released, we've hit a full feature
freeze (and this is definitely a feature).

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:45>

Django

unread,
Mar 3, 2010, 7:54:12 PM3/3/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by brentp):

current patch does not respect limit_choices_to when specified for a
ForeignKey.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:46>

Django

unread,
Mar 12, 2010, 10:58:01 AM3/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by broderboy):

* cc: timothy...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:47>

Django

unread,
Apr 18, 2010, 9:20:52 PM4/18/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by anonymous):

* cc: gabrielhurley (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:48>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-...@googlegroups.com.
To unsubscribe from this group, send email to django-update...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.

Django

unread,
May 12, 2010, 6:08:12 AM5/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by DrMeers):

* cc: DrMeers (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:49>

Django

unread,
May 19, 2010, 2:07:43 PM5/19/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by SamBull):

* cc: osi...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:50>

Django

unread,
Jun 27, 2010, 7:20:12 AM6/27/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by isometry):

* cc: isometry (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:51>

Django

unread,
Jul 8, 2010, 9:59:26 AM7/8/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by frans):

[#comment:46 good point by brentp]. I've tried to have a crack at it but
got lost in the the bowels of limit_choices_to. If anyone who knows the
innards can sketch an approach, I don't mind tackling the actual
patching/testing.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:52>

Django

unread,
Jul 11, 2010, 12:39:58 AM7/11/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by mitar):

* cc: mmi...@tnode.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:53>

Django

unread,
Jul 11, 2010, 12:55:36 AM7/11/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by mitar):

Reverse relationship support would be really great as then it would be
possible to extend `list_filter` for `UserAdmin` with fields from profile.
Profile have `OneToOneField` or `ForeignField` field defined which point
back to `django.contrib.auth.models.User` model and currently it is not
possible to extend admin to filter by fields in the profile. (While it is
possible to extend searchable fields.)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:54>

Django

unread,
Jul 11, 2010, 5:18:21 PM7/11/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Comment (by DrMeers):

I have written a patch which works for reverse relationships also;
anything you can put in {{{search__fields}}} now works for
{{{list__filter}}} also. Just tidying up implementation,
{{{limit_choices_to}}}, etc, will upload shortly.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:55>

Django

unread,
Aug 5, 2010, 9:14:09 AM8/5/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: jakub_vysoky
Status: new | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by foxwhisper):

* cc: c...@foxwhisper.co.uk (added)

Comment:

Hello,

Can DrMeers please upload his most recent patch please?

Cheers

Cal

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:56>

Django

unread,
Aug 9, 2010, 12:11:39 AM8/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by DrMeers):

* owner: jakub_vysoky => DrMeers
* needs_better_patch: 1 => 0
* status: new => assigned
* needs_tests: 1 => 0

Comment:

OK, here is my draft patch. I have not tested it thoroughly; there may
still be a few issues to smooth out, so test-drivers would be appreciated.

A few notes:

* Reverse relationships work
* You can now use any field path that search_filters will accept
* I have removed the strict validation in favour of letting
setup_joins catch any issues, as search_fields does. We could perhaps look
at adding admin validation for field paths for both instead.
* I played around with combining multiple limit_choices_to clauses
based on the models in the field path, however discovered that in practise
it really doesn't make sense to apply any before the final model in the
field path
* limit_choices_to is respected for AllValuesFilterSpec, and a utility
function is provided if other filterspecs wish to do likewise
* There are some basic tests included in the patch

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:57>

Django

unread,
Aug 20, 2010, 4:31:35 AM8/20/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by frans):

after testing this patch on my dev/test instance successfully, I'll deploy
on my prod server and report

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:58>

Django

unread,
Aug 25, 2010, 9:01:12 PM8/25/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by 3point2):

* cc: 3point2 (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:59>

Django

unread,
Sep 4, 2010, 4:43:18 AM9/4/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by frans):

all good in prod for me so far... Will update if I notice anything out of
the ordinary

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:60>

Django

unread,
Sep 6, 2010, 10:44:36 AM9/6/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 1
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by foxwhisper):

* needs_tests: 0 => 1

Comment:

Deployed to dev and all looks fine so far.. will let you guys know if
anything bad happens. Thanks dr meers!

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:61>

Django

unread,
Sep 6, 2010, 5:03:54 PM9/6/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by DrMeers):

* needs_tests: 1 => 0

Comment:

Did you not notice the included tests? If there is a particular aspect you
thought was untested, please let me know and I'll add it.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:62>

Django

unread,
Sep 7, 2010, 5:18:10 AM9/7/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by foxwhisper):

Hi DrMeers,

I actually had problems merging the tests in, the patch file said the path
specified for the tests was not valid, but it worked on the other files,
so I marked it as "needs tests" but I prob should have marked it as patch
needs improvement.

Also, I'm getting problems now in production, which I will attempt to fix
later:


Environment:

Request Method: GET
Request URL: http://dev.app.textrecommend.co.uk/admin/mvoucher/vouchersms/
Django Version: 1.2 beta 1
Python Version: 2.6.5
Installed Applications:
['webapp.mvoucher',
'webapp.djangoextend',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'webapp.djangoextend.djangologging.middleware.SuppressLoggingOnAjaxRequestsMiddleware',
'webapp.djangoextend.djangologging.middleware.LoggingMiddleware',
'webapp.djangoextend.core.GlobalRequestMiddleware',
'webapp.djangoextend.middleware.DjangoExtendMiddleware')


Traceback:
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/options.py" in wrapper
243. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/utils/decorators.py" in _wrapped_view
74. response = view_func(request, *args, **kwargs)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/views/decorators/cache.py" in _wrapped_view_func
69. response = view_func(request, *args, **kwargs)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/sites.py" in inner
194. return view(request, *args, **kwargs)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/utils/decorators.py" in _wrapper
21. return decorator(bound_func)(*args, **kwargs)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/utils/decorators.py" in _wrapped_view
74. response = view_func(request, *args, **kwargs)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/utils/decorators.py" in bound_func
17. return func(self, *args2, **kwargs2)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/options.py" in changelist_view
970. self.date_hierarchy, self.search_fields,
self.list_select_related, self.list_per_page, self.list_editable, self)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/views/main.py" in __init__
71. self.filter_specs, self.has_filters =
self.get_filters(request)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/views/main.py" in get_filters
81. field_path=filter_name)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/filterspecs.py" in create
39. field_path=field_path)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/filterspecs.py" in __init__
201. limit_choices_to = get_limit_choices_to_from_path(model,
field_path)
File "/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/util.py" in get_limit_choices_to_from_path
421. hasattr(fields[-1], 'rel') and

Exception Type: IndexError at /admin/mvoucher/vouchersms/
Exception Value: list index out of range

/home/textrecommend/local/lib/python2.6/site-
packages/django/contrib/admin/util.py in get_limit_choices_to_from_path
hasattr(fields[-1], 'rel') and ...
▼ Local vars
Variable Value
fields
[]
model
<class 'webapp.mvoucher.models.VoucherSMS'>
path
'carrier_status_code'



# If the carrier returns a status code, this is placed into here.
carrier_status_code = models.CharField(max_length=64, blank=True,
null=True)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:63>

Django

unread,
Sep 7, 2010, 5:36:24 AM9/7/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 1 |
-------------------------------------------+--------------------------------
Changes (by foxwhisper):

* needs_better_patch: 0 => 1

Comment:

I fixed this by changing:

django/contrib/admin/util.py

{{{
#!python
def get_limit_choices_to_from_path(model, path):
""" Return Q object for limiting choices if applicable.

If final model in path is linked via a ForeignKey or ManyToManyField
which
has a `limit_choices_to` attribute, return it as a Q object.
"""
fields = get_fields_from_path(model, path)
fields = remove_trailing_data_field(fields)
+ if len(fields)==0:
+ return models.Q()
limit_choices_to = (
hasattr(fields[-1], 'rel') and
getattr(fields[-1].rel, 'limit_choices_to', None))
if not limit_choices_to:
return models.Q() # empty Q
elif isinstance(limit_choices_to, models.Q):
return limit_choices_to # already a Q
else:
return models.Q(**limit_choices_to) # convert dict to Q
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:64>

Django

unread,
Sep 9, 2010, 9:27:00 PM9/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by DrMeers):

* needs_better_patch: 1 => 0

Comment:

Thanks foxwhipser, patch updated.

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:65>

Django

unread,
Oct 9, 2010, 1:35:13 AM10/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by alexkoshelev):

* cc: alexkoshelev (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:66>

Django

unread,
Oct 12, 2010, 12:41:35 AM10/12/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by m4rt0g1):

can anyone mail me about which file that needed to be change and full
example for doing this code?

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:67>

Django

unread,
Nov 9, 2010, 10:02:02 PM11/9/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by simon29):

* cc: simon29 (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:68>

Django

unread,
Nov 10, 2010, 7:00:40 PM11/10/10
to djang...@holovaty.com, django-...@googlegroups.com
#3400: Support for lookup separator with list_filter admin option
-------------------------------------------+--------------------------------
Reporter: ni...@intv.com.au | Owner: DrMeers
Status: assigned | Milestone: 1.3
Component: django.contrib.admin | Version: newforms-admin
Resolution: | Keywords: edc nfa-someday list_filter FilterSpec nfa-changelist ep2008
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Changes (by mark0978):

* cc: mark0978 (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/3400#comment:69>
Reply all
Reply to author
Forward
0 new messages