Hello!

I know this a very stupid question but nevertheless how can I get
request.user object in forms.py file ? I am trying  to do something
like:

class ItemGetForm(forms.Form):
    box = forms.ModelMultipleChoiceField(
        queryset=Box.objects.filter(owner=request.user),
        widget=forms.RadioSelect)
    label = forms.IntegerField()

Where:

class Box(models.Model):
    owner = models.ForeignKey(User)
    description = models.CharField(max_length=500, blank=True, null=True)

    def __unicode__(self):
        return self.description


But constantly get an error 'Caught an exception while rendering: name
'request' is not defined'.

If am completely wrong here what is a preferable way of doing such things ?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to