I'm just wondering, but in general, isn't the use of threadlocals kind of hacky? Shouldn't there be a more approach to this?
Erik On 20.08.2008, at 0:12, brentp wrote: > > On Aug 19, 9:14 am, patrickk <[EMAIL PROTECTED]> wrote: >> it´s basically for autopopulating a form. I´m not setting the user >> here, I just want data which is assigned to that user only. I could >> use the forms __init__ to achieve this, but it´s easier to use >> limit_choices ... moreover, the functionality of the admin-interface >> would reflect the functionality of the site. >> >> thanks, >> patrick >> >> On Aug 19, 5:48 pm, "Emily Rodgers" <[EMAIL PROTECTED]> wrote: >> >>>> -----Original Message----- >>>> From: django-users@googlegroups.com >>>> [mailto:[EMAIL PROTECTED] On Behalf Of patrickk >>>> Sent: 19 August 2008 14:12 >>>> To: Django users >>>> Subject: limit choices to logged-in user >> >>>> is there a way to limit choices (using foreign key) to the >>>> logged-in user? >> >>>> I´ve tried limit_choices_to = {'user': request.user}, but >>>> that is obviously not working since "request" is not available. >> >>>> any ideas? >> >>> What are you trying to do exactly? Is this to auto populate some >>> kind of >>> form, or just for data integrity? >> >>> If I have a model that has a user field, and I want it to be the >>> remote >>> user, I normally just set this in my view. Not sure if this is the >>> best >>> thing to do but it seems to work for me. > > hi, you can use this: > http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser > and then something like. > limit_choices_to = { 'user': get_current_user() } > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---