On Sat, Aug 1, 2009, Ramiro Morales <[email protected]> wrote:
>If you need this for the admin app and are using Django 1.1 read about
>the formfield_for_foreignkey ModelAdmin method:
>
>http://docs.djangoproject.com/en/dev/ref/contrib/admin/
>#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
>
>you can write your own and further filter the queryset used for
>the FK field UI there, an example is included in the documentation
Thanks, I hadn't seen formfield_for_foreignkey before.
Part of that example goes does this:
Car.objects.filter(owner=request.user)
using the User instance as the basis for filtering. How could I refer to
the current instance of the model, to use that for filtering?
In my case the model is Person, and field I want to get the choices from
is Entities.people (its related_name). So it owuld be something like:
Entities.objects.filter(people=[this instance of Person])
Daniele
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---