> > I'm after a way of limiting what choices are populated into a drop-down > box from a foreign key field when I'm using the generic create/update views:
I would recommend not using the generic create/update views as those views use old forms and manipulators which are going away in favor of "newforms". Take a look at the newforms documentation here: http://www.djangoproject.com/documentation/newforms/ In particular, read the sub-sections on "form_for_model" and "form_for_instance" which will let you get handy newforms instances that can respectively create and update a Customer record. > > What I am trying to achieve is to be able to limit the list of domains > that a reseller can apply to their customer objects to domains that they > have control of: When you acquire a Customer newform instance in your view, you will be able to modify the choices attribute of its domain field so that these choices only contain the relevant domains that you mentioned you can trivially derive knowing the request.user. > I think I need to be able to resolve the logged in username into a list > of groups (which I can do with request.user.groups) and then resolve > that into the list of resellers and then resolve that into a list of > domains. I don't think I can access the request object from the model can I? Its possible to do this through a hack that (http://lukeplant.me.uk/ blog.php?id=1107301634) but it's not a good practice to closely couple your view code (i.e. the request object) with your model code. You won't need to resort to this anyway if you are willing to write your own newforms based view suggested above. -Rajesh D. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---