How to add queryset to ManyToMany relationship?
<p>I have following models:</p>

<pre><code>class EnMovielist(models.Model):
    content_ID = models.CharField(max_length=30)
    release_date = models.CharField(max_length=30)
    running_time = models.CharField(max_length=10)
    actress = models.CharField(max_length=300)
    series = models.CharField(max_length=30)
    studio = models.CharField(max_length=30, null=True)
    director = models.CharField(max_length=30)

    def __str__(self):
        return self.content_ID


class EnActress(models.Model):
    name = models.CharField(max_length=100, null=True)
    movielist = models.ManyToManyField(EnMovielist, related_name='movies')

    def __str__(self):
        return self.name
</code></pre>

<p>I got error when I try to this in Django shell,</p>

<pre><code>b = EnActress.objects.values_list('name', flat=True)
a = EnMovielist.objects.filter(actress__contains=b).values_list('content_ID')

b.movielist.add(a)



AttributeError: 'QuerySet' object has no attribute 'movielist'
</code></pre>

<p>How can I django queryset add into many-to-many field?
I have no idea why this is happening.. Any help appreciated! :)</p>

<p>You should not be using <code>values_list</code> if you intend to <code>add</code> a new relation afterwards. From the <a href="https://docs.djangoproject.com/en/1.10/ref/models/querysets/#values-list" rel="nofollow">docs</a>:</p>

<blockquote>
  <p><code>values()</code> and <code>values_list()</code> are both intended as optimizations for
  a specific use case: retrieving a subset of data <strong>without the
  overhead of creating a model instance</strong></p>
</blockquote>

<p>[<em>Emphasis mine</em>]</p>

<p>It's hard to tell what you're up to without having a good description of what you want to achieve.</p>

python django django-queryset manytomanyfield