title: Django - get data from foreign key
body: <p>I'm working on a Django project and attempting to create some linked models for my data which In think is working, but I cannot seem to work out how to access the linked data.</p>
  
  <pre><code>class One(models.Model)
    name = models.CharField(max_length=50)
    list = models.ArrayField(models.CharField(max_length=50), blank=True)
  
    def __str__(self): 
      return self.name
  
  class Many(models.Model)
    name = models.CharField(max_length=50)
  
    related = models.ForeignKey(One, null=True, blank=True)
  
    def __str__(self): 
      return self.name    
  </code></pre>
  
  <p>This is the general relationship I have set up.</p>
  
  <p>What I am trying to do is, in a template have access to a list of all 'Ones', and via each of those, can access each Many and it's related attributes. I can see how to access the attributes for a single 'One', but not how to pass all of them and their related 'Many' models and the related attributes for each. Essentially the output I'd like would have a drop down list with the One's, and when this is submitted some Javascript will use the list in the 'Many' model to do some stuff.</p>
  
  <p>Any advice would be much appreciated. </p>