Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I do not think you are understanding the manufacturer to vehicle relationship property. What I think you are trying to show is that a certain <code>Vehicle</code> belongs to a certain <code>manufacturer</code>.</p> <p>This type of relationship would actually be defined in the <code>Vehicle</code> class, as a foreign key, called <code>manufacturer</code>, in the <code>Vehicle</code> class.</p> <p>In the case you are defining many vehicles under a manufacturer, you just need to rename the property to <code>car_model</code> or something of the like and you should be fine.</p> <p>I think you have the understanding mapped out well enough. Just remember that foreign keys are only a property of one table, and say nothing about the other table itself until the relationship is established there also.</p> <p>If you're working with a larger relationship, with multiple objects, you should look into using the Many-to-many field described in the <a href="https://docs.djangoproject.com/en/dev/topics/db/examples/many_to_many/" rel="nofollow">django documentation</a>.</p> <p>They have an example that shows how an Articles have many Publications:</p> <pre><code>class Publication(models.Model): title = models.CharField(max_length=30) # On Python 3: def __str__(self): def __unicode__(self): return self.title class Meta: ordering = ('title',) class Article(models.Model): headline = models.CharField(max_length=100) publications = models.ManyToManyField(Publication) # On Python 3: def __str__(self): def __unicode__(self): return self.headline class Meta: ordering = ('headline',) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload