title: Loop through two querysets while highlighting differences in django
body: <p>I have a model class defined as below:</p>
  
  <pre><code>class Vehicle(models.Model):
      stock_number = models.CharField(max_length=6)
      vin = models.CharField(max_length=17)
      year = models.PositiveSmallIntegerField()
      manufacturer = models.CharField(max_length=15)
      manufacturer_popularity = models.CharField(max_length=1, blank=True, null=True)
      model = models.CharField(max_length=20)
      series = models.CharField(max_length=35, blank=True, null=True)
      exterior_colour = models.CharField(max_length=25)
      interior_colour = models.CharField(max_length=25)
      interior_type = models.CharField(max_length=25)
      doors = models.PositiveSmallIntegerField()
      passengers = models.PositiveSmallIntegerField()
      body_style = models.CharField(max_length=30)
      transmission = models.CharField(max_length=50)
      fuel_type = models.CharField(max_length=50)
      engine_capacity = models.DecimalField(max_digits=2, decimal_places=1)
      cylinders = models.PositiveSmallIntegerField()
      drive_train = models.CharField(max_length=50)
  </code></pre>
  
  <p>What I want to do is to query two databases based on the above class then display the data in a template while showing the differences between each paired Vehicle entry in red.  The querying bit isn't the main issue I guess since I'll need something like:</p>
  
  <pre><code>set1 = Vehicle.objects.all()
  set2 = Vehicle.objects.using('other_db').all()
  </code></pre>
  
  <p>But how can I have the pairing and display being handled?  I hope someone can show me the light here.</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <pre><code>vehicles = []
  for v1 in set1:
      for v2 in set2:
          if v1['stock_number'] == v2['stock_number']:
              vehicle1 = vehicle2 = {}
              vehicle1['vehicle_1'] = v1
              vehicle2['vehicle_2'] = v2
              vehicles.append(vehicle1)
              vehicles.append(vehicle2)
          else:
              vehicle1 = vehicle2 = {}
              vehicle1['vehicle_1'] = v1
              vehicle2['vehicle_2'] = {}
              vehicles.append(vehicle1)
              vehicles.append(vehicle2)
  </code></pre>