Not sure where to start... Just hoping someone can give me a kick in
the right direction.
I have built a flat page app that allows for an author FK (optional field).
When I setup the admin to allow author as a list_filter, the actual
filter list of authors is way to long to be useful.
Would it be possible for me to setup my list_filter to only show
author names that have been assigned to my flat pages? For example,
let's say I have 10 pages, and two of those pages have the been FK'd
to "bjohnson" and "fjackson"... In my list_filter view, I would like
to only see "bjohnson" and "fjackson".
Does any of this make sense? :D
Any tips and/or advice would be awesome.
Thanks!
Micky
Just as an update, I found this:
<https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_filter>
... and it looks like what I need... Unfortunately, it's new in trunk
(I'm on 1.3).
I am hoping there's something similar to SimpleListFilter in 1.3.
I'm now trying to figure out how to browse Django source for version 1.3. :)
I will post back with more info if I figure something out.
Thanks!
Micky
Cool, found 1.3 source:
django/branches/releases/1.3.X
<https://code.djangoproject.com/browser/django/branches/releases/1.3.X>
Looks like maybe FilterSpec might be what I want:
At least now I have a better idea of what to Google for "django
FilterSpec author". :)
Thanks!
Micky
On top of needing to limit list_filter in the admin, I also needed to
limit the user choices in my FK to auth.user. This bit of code does
just that:
<https://gist.github.com/1719713>
Just thought I would share the code to help others.
I am wondering if I can apply the same logic, as a method, to list_filter?
list_filter = SomeMethod()
(probably not, but that would be nice)
Anywho... Anyone know when Django 1.4 is scheduled to be released?
[quote]
The Django 1.4 roadmap
Before the final Django 1.4 release, several other preview/development
releases will be made available. The current schedule consists of at
least the following:
* Week of January 30, 2012: First Django 1.4 beta release; final
feature freeze for Django 1.4.
* Week of February 27, 2012: First Django 1.4 release candidate;
string freeze for translations.
* Week of March 5, 2012: Django 1.4 final release.
If necessary, additional alpha, beta or release-candidate packages
will be issued prior to the final 1.4 release. Django 1.4 will be
released approximately one week after the final release candidate.
[/quote]
--<https://docs.djangoproject.com/en/dev/releases/1.4-alpha-1/#the-django-1-4-roadmap>