title: Django QuerySet in template for relational models
body: <p>I am trying to setup a relation with another model using FK in django but I can't call FK related model fields in django templates. In template when I call "provider.name" it shows me "None" as result. I do have 5 different suppliers listed and can see from admin. I have providers and I got products like below:</p>
  
  <pre><code>class Product(models.Model):
      title = models.CharField(max_length=500)
      description = models.TextField(blank=True, null=True)
      price = models.DecimalField(max_digits=20, decimal_places=2)
      sku = models.CharField(null=True, max_length=100)
      url = models.URLField(blank=True)
      slug = models.SlugField(unique=True)
      providers = models.ManyToManyField('Provider', blank=True)
  
      def __unicode__(self):
          return self.title
  
     class Provider(models.Model):
      name = models.CharField(max_length=200)
      description = models.TextField(null=True, blank=True)
      logo = models.ImageField(upload_to='products/')
      shipping_method = models.CharField(max_length=250)
      shipping_time = models.CharField(max_length=250)
      return_policy = models.CharField(max_length=200)
      free_delivery = models.CharField(max_length=200)
      customer_service_number = models.CharField(max_length=200)
      shipping_charges = models.CharField(max_length=200)
  
      def __unicode__(self):
          return self.name
  </code></pre>
  
  <p>In template the way I am calling it is:</p>
  
  <pre><code>{% with provider=object.providers %}
  {{ provider.name }}
  {% endwith %}
  </code></pre>
  
  <p>As result it shows <code>"None"</code>. I am trying to call provider in a different template. In it's own List/Detail generic views it works just fine. I am trying to call it in different app templates. Please advise. </p>
  
  <p>Update................</p>
  
  <p>My search.html for whoosh search engine includes</p>
  
  <pre><code>{% for result in page.object_list %}
              &lt;div class="col-lg-1-5  col-md-3 col-sm-4 col-xs-12"&gt;
              &lt;div class="pbox"&gt;
                &lt;div class="photo"&gt;
                  &lt;a href="{{ result.object.get_absolute_url }}"&gt;&lt;img src="{{ result.object.get_image_url }}" alt="product"&gt;&lt;/a&gt;
                &lt;/div&gt;
                &lt;div class="info"&gt;
                  &lt;div class="url"&gt;
                  name
                      {% for item in result.object.providers.all %}
                          {{ result.provider.name }}
                      {% endfor %}
  
                  &lt;/div&gt;
                  &lt;div class="description"&gt;
                    {{ result.object.description|truncatewords:7 }}
                  &lt;/div&gt;
                  &lt;div class="price"&gt;
                    {{ result.object.price|intcomma }}
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
  </code></pre>
  
  <p>As I am not using any ModelManager or just using default Managers pre-defined for models. I've added a line of code under Product App model like this:</p>
  
  <pre><code>def get_provider(self):
          item = self.providers.all()
          return item
  </code></pre>