Oh. It doesn't mention that in the documentation. I am using 1.0.2-
final. I'll check out formfield_for_dbfield. Thanks for the pointer!

On Feb 12, 3:09 pm, Alex Gaynor <[email protected]> wrote:
> On Thu, Feb 12, 2009 at 3:07 PM, Michael Repucci <[email protected]>wrote:
>
>
>
>
>
> > I'm new to Django, and already loving it. But I'm stumbling a bit with
> > how to accomplish the following task. Perhaps this isn't the best
> > approach, but most of the site is working as planned, and it was super
> > easy to get up and running.
>
> > I have a Contact model and a Person model, the latter of which has a
> > ForeignKey field (contact) to a Contact instance. Both Contact and
> > Person models have an owner field (also ForeignKey), so that I can
> > associate a particular User (django.contrib.auth.models) through the
> > admin site with their own Contact and Person instances. That way, I
> > can filter the admin site, so that each User (aside from superusers)
> > sees only their own Contact and Person instances.
>
> > This all works marvelously, except in one place: on the default
> > <select> box for the contact field on the Person add/change form on
> > the admin site. I can't seem to find out how to filter the Contact
> > instances by User when displaying this select box. I thought the
> > solution would be through the formfield_for_foreignkey method, but I
> > implemented it as described in the admin site documentation, and it
> > doesn't work. I would try to debug it a bit, but don't really know how
> > to get it to output any values for me.
>
> > So please help me learn how to debug formfield_for_foreignkey, if that
> > is the right solution, or offer a different approach. Please do try to
> > take me slowly through any suggestion(s) you may have, and point me
> > toward documentation, if available, as I am totally new to this. Thank
> > you!
>
> What version of Django are you running?  The formfield_for_foreignkey hook
> only exissts in trunk, not in 1.0.2, so if you're on 1.0.2 you'll need to
> overide the formfield_for_dbfield method, which is a little more general.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~---------~--~----~------------~-------~--~----~
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