From 3ccae4e2f6da4ef22ed8aedef236c6a00a2edcb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4ufl?= Date: Tue, 9 Feb 2016 21:31:47 +0100 Subject: [PATCH] [sensors] Added unique together --- .../migrations/0016_auto_20160209_2030.py | 23 +++++++++++++++++++ feinstaub/sensors/models.py | 3 +++ 2 files changed, 26 insertions(+) create mode 100644 feinstaub/sensors/migrations/0016_auto_20160209_2030.py diff --git a/feinstaub/sensors/migrations/0016_auto_20160209_2030.py b/feinstaub/sensors/migrations/0016_auto_20160209_2030.py new file mode 100644 index 0000000..1e69f20 --- /dev/null +++ b/feinstaub/sensors/migrations/0016_auto_20160209_2030.py @@ -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')]), + ), + ] diff --git a/feinstaub/sensors/models.py b/feinstaub/sensors/models.py index 537d152..2030394 100644 --- a/feinstaub/sensors/models.py +++ b/feinstaub/sensors/models.py @@ -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,