title: Django get fields of ForeignKey object in models
body: <p>I have these two models defined with a one to many relationship</p>
  
  <p>from django.core.validators import RegexValidator
     from django.db import models</p>
  
  <pre><code>class Template(models.Model):
      name = models.CharField(max_length=100)
      fields = models.IntegerField()
  
      def __str__(self):
          return self.name
  
  
  class Page(models.Model):
      template = models.ForeignKey(Template, related_name='pages')
  
      title = models.CharField(max_length=100)
  
      text = []
  
      for i in range(template.fields):   #Error occuring here
          text[i] = models.TextField()
  
      def __str__(self):
          return self.title
  </code></pre>
  
  <p>I want to get the value of template.fields, but I get this error</p>
  
  <pre><code>for i in range(template.fields):
  AttributeError: 'ForeignKey' object has no attribute 'fields'
  </code></pre>
  
  <p>Am I using the ForeignKey Object wrong? Any help would be much appreciated</p>