Skip to content

Commit

Permalink
[sensors] Added unique together
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-k committed Feb 9, 2016
1 parent edb2cf2 commit 3ccae4e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
23 changes: 23 additions & 0 deletions feinstaub/sensors/migrations/0016_auto_20160209_2030.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-09 20:30
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('sensors', '0015_sensordata_software_version'),
]

operations = [
migrations.AlterModelOptions(
name='sensordatavalue',
options={},
),
migrations.AlterUniqueTogether(
name='sensordatavalue',
unique_together=set([('sensordata', 'value_type')]),
),
]
3 changes: 3 additions & 0 deletions feinstaub/sensors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class SensorDataValue(TimeStampedModel):
value_type = models.CharField(max_length=100, choices=SENSOR_TYPE_CHOICES,
db_index=True)

class Meta:
unique_together = (('sensordata', 'value_type', ), )

def __str__(self):
return "{sensordata}: {value} [{value_type}]".format(
sensordata=self.sensordata,
Expand Down

0 comments on commit 3ccae4e

Please sign in to comment.