title: Django models relationship tests
body: <p>I am new to django testing and have some issues using them to test relationship between models.</p>
  
  <p>Here is an extract of my models:</p>
  
  <pre><code>class Member(models.Model):
      user = models.OneToOneField('auth.User')
      points = models.IntegerField()
  
      def __unicode__(self):
          return self.points
  
      def get_number_of_poll(self):
          nbr_of_poll = Poll.objects.filter(user=self.user).count()
          return nbr_of_poll
  
  class Poll(models.Model):
      question = models.CharField(max_length=200)
      user = models.ForeignKey(User)
  
      def __unicode__(self):
          return self.question
  </code></pre>
  
  <p>And here are the tests:</p>
  
  <pre><code>from polls.models import Member, Poll
  from django.contrib.auth.models import User
  from django.test import TestCase
  
  class MemberTestCase(TestCase):
      def setUp(self):
          user = User(username='user')
          self.member = Member(user=user, points=5000)
          poll = Poll(question='poll', user=user)
  
      def test_get_number_of_poll(self):
          self.assertEqual(self.member.get_number_of_poll(), 1)
  </code></pre>
  
  <p>The issue is with the <code>test_get_number_of_poll()</code> method that always returns 0. The code works as expected on the site. 
  Am I doing something wrong with the test? I am not sure how I am supposed to set the poll in the test class.</p>