Is it possible to use limit_choices_to with a dynamic model attribute?

Some background: I am using a StaffMember model for content creators
who do not have user accounts. Each staff member has a start and end
date and the model has a dynamic attribute called 'is_active' that
compares the start/end dates to the current date and returns either
True or False depending on whether the staff member is active or not.

When creating content, I need to be able to use limit_choices_to to
limit the drop-down choices to only those staff members that are
currently active (otherwise we'll have hundreds of inactive alumni
staff showing up in the list of choices every time we post new
content). Django returns a "Cannot resolve keyword 'is_active' into
field" error when I try to do this.

I could add an "is_active" field to the StaffMember model, but that
would be redundant given the start/end dates and would require admins
to manually keep track of staff members in a high turn-over
environment.

On a related note, the dynamic attribute works with list_display but
not list_filter in admin.py.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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