Re: ManyToManyField, limit_choices_to and properties of the request object
Brilliant - thanks, Sam. Is this in the docs anywhere, I wonder? I've seen a few queries along these lines. Might be an FAQ Q --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToManyField, limit_choices_to and properties of the request object
On Mon, 19 Mar 2007 09:29:08 -0700, quentinsf wrote: > I need to do something similar. In a form I want to limit the options > in a ForeignKey's pull-down select field to objects owned by an > organisation of which the user is a member. > > I've been trying to work out where this would fit. Any help much > appreciated. It turns out that you can just set the field's choices after the manipulator has been created: m = Post.AddManipulator () m['images'].choices = [(i.id, i) for i in Image.objects.filter (author = request.user)] -- Sam Morris http://robots.org.uk/ PGP key id 1024D/5EA01078 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ManyToManyField, limit_choices_to and properties of the request object
I need to do something similar. In a form I want to limit the options in a ForeignKey's pull-down select field to objects owned by an organisation of which the user is a member. I've been trying to work out where this would fit. Any help much appreciated. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
ManyToManyField, limit_choices_to and properties of the request object
Is it possible to use a ManyToManyField's limit_choices_to attribute to limit a user to picking only from related objects that have author = request.user? Given that request has no place in the model definition, would it be necessary to write a custom manipulator? -- Sam Morris http://robots.org.uk/ PGP key id 1024D/5EA01078 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 signature.asc Description: This is a digitally signed message part