yes, gotcha - that makes sense. Thanks. Margie
On May 7, 10:59 pm, George Song <geo...@damacy.net> wrote: > On 5/7/2009 9:19 PM, Margie wrote: > > > > > Thanks much George, that was a big help. I have some "proof of > > concept code below" that simply limits choices to the first four > > users, and I have verified that that works. > > > class TaskAdmin(admin.ModelAdmin): > > > def formfield_for_dbfield(self, db_field, **kwargs): > > if db_field.name == "owner": > > kwargs["queryset"] = User.objects.all()[0:3] > > formField = super(TaskAdmin, self).formfield_for_dbfield > > (db_field, **kwargs) > > return formField > > > I think that at the time formfield_for_dbfield is called we are > > creating the class for the form, ie, in this case, the class > > TaskForm. It seems to me that I don't have any info at this time > > about what the actual values of the manyToMany field 'resources' is. > > In fact, it may be different for each line in the admin display. IE, > > for each line in the admin display, resources may point to different > > users and it is the value of resources hat I would really like to have > > for my choices for the owner field. I have a feeling this isn't going > > to be possible ... > > > It seems like I would need to be setting the queryset for owner at a > > much later point in the code to really be able to set it to the > > 'resources' field for that same task. > > If you can't predict ahead of time what the choice set is, then you will > have to use some AJAX magic to accomplish what you want. The nice thing > is you can attach JS to the fields you want. > > -- > George --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---