Hey, I'm basically trying to filter a foreign key (using limit_choices_to) by an user (just like in this thread http://groups.google.com/group/django-users/browse_thread/thread/8006b7e493ef877d/79d5c10c3abab725?lnk=st&q=limit_choices_to+threads&rnum=2#79d5c10c3abab725)
The model is quite simply, as you may guess: class Practica(models.Model): asignatura = models.ForeignKey(Asignatura, blank=False, limit_choices_to = {'owner' : ##current_user##}) class Asignatura(models.Model): owner = models.ForeignKey(User, blank=False, limit_choices_to={'is_staff__exact' : 1}) The first limit_choices_to is the one which is not working. I tried threadlocals (http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser) unsucessfully ( limit_choices_to = {'owner' : get_current_user()}) ). I realized that the evaluation of get_current_user() wasn't done during runtime but just once at the very beggining. So I guessed that a lazy version of get_current_user should be needed for that (as Luke suggested in this other thread: http://groups.google.com/group/django-users/browse_thread/thread/5d89dc0c2aa3927b/f19dba6f48bb6060?lnk=gst&q=lazyuser&rnum=1#f19dba6f48bb6060) And then I discovered LazyUser in django/contrib/auth/middleware.py (http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/middleware.py?rev=3754) It is not documented any where, and not found very much information about. Neither it is used in django trunk code. So I tried to use it with limit_choices_to like somekind of LazyDate(), but with, again, no results. Also I'm not pretty sure what kind of object it returns. Maybe some django-guru could help me in this?? I'm very surprised this is not a hot django topic and not so much information can be found in google about it. I can't believe that no one has needed this before... thanks in advance! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---