title: Django 1.3 CreateView, ModelForm and filtering fields by request.user
body: <p>I am trying to filter a field on a ModelForm. I am subclassing the generic CreateView for my view. I found many references to my problem on the web, but the solutions do not seem to work (for me at least) with Django 1.3's class-based views.</p>
  
  <p>Here are my models:</p>
  
  <pre><code>#models.py
  
  class Subscriber(models.Model):
  
      user = models.ForeignKey(User)
      subscriber_list = models.ManyToManyField('SubscriberList')
      ....
  
  class SubscriberList(models.Model):
  
      user = models.ForeignKey(User)
      name = models.CharField(max_length=70)
  ....
  </code></pre>
  
  <p>Here is my view:</p>
  
  <pre><code>#views.py
  
  class SubscriberCreateView(AuthCreateView):
      model = Subscriber
      template_name = "forms/app.html"
      form_class = SubscriberForm
      success_url = "/app/subscribers/"
  
      def form_valid(self, form):
          self.object = form.save(commit=False)
          self.object.user = self.request.user
          return super(SubscriberCreateView, self).form_valid(form) 
  </code></pre>
  
  <p>Here is my original form for adding a Subscriber, with no filter:</p>
  
  <pre><code>#forms.py
  
  class SubscriberForm(ModelForm):
  
      class Meta:
          model = Subscriber
          exclude = ('user', 'facebook_id', 'twitter_id')
  </code></pre>
  
  <p>Here is my modified form, attempting to filter, but doesn't work:</p>
  
  <pre><code>#forms.py
  
  class SubscriberForm(ModelForm):
  
      class Meta:
          model = Subscriber
          exclude = ('user', 'facebook_id', 'twitter_id')
  
      def __init__(self, user, **kwargs):
          super(SubscriberForm, self).__init__(**kwargs)
          self.fields['subscriber_list'].queryset = SubscriberList.objects.filter(user=user)
  </code></pre>
  
  <p>If I change this modified form as so:</p>
  
  <p><code>def __init__(self, user=None, **kwargs)</code></p>
  
  <p>It works - It brings me NO subscriber lists. But any way I try to pass the request user, I invariably get a a name "request" or name "self" not defined error.</p>
  
  <p>So, how can I modify my code to filter subscriber_list by the request.user, and still use Django 1.3's CreateView.</p>