title: How can I properly use related_name in django models to get back the class name?
body: <p>I have an application called "school" inside one of my django projects.</p>
  
  <p><strong>Below is the code of models.py</strong></p>
  
  <pre><code>from django.db import models
  
  class Student(models.Model):
      name = models.CharField(max_length=255)
      birthday = models.DateField(blank=True)
  
  class Class(models.Model):
      name = models.CharField(max_length=255)
      student = models.ForeignKey(Student,related_name='classes',null=True)
  
      def __str__(self):
          return self.name
  </code></pre>
  
  <p><strong>And now, views.py:</strong></p>
  
  <pre><code>from django.shortcuts import render
  from .models import *
  
  def test(request):
      obj2 = Student.objects.get(name='john')
      return render(request,'test/list.html', {'obj2':obj2} )
  </code></pre>
  
  <p><strong>And finally, my template looks like this:</strong></p>
  
  <pre><code>{% block content %}
  &lt;h2&gt;
  {{ obj2.classes }}
  &lt;/h2&gt;
  {% endblock %}
  </code></pre>
  
  <p>In my template, I am using obj2.classes (i.e., responseobject.related_name). I want it to print the class name.
  However when I access the site at <a href="http://127.0.0.1:8000/shop/" rel="nofollow">http://127.0.0.1:8000/shop/</a> ,
  it gives me this output:</p>
  
  <pre><code>shop.Class.None
  </code></pre>
  
  <p>How will I get the output as only "Class", that is the class name?</p>