Ah, after playing with the code some more I resolved my own problem.
Instead of relying on the 'is_active' dynamic model attribute for use
with limit_choices_to, I was able to get the following to accomplish
the same task:
limit_choices_to={ 'end_date__gte': datetime.date.today,
'start_date__lte': datetime.date.today }
On Mar 30, 1:53 pm, Jamie <[email protected]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---