Форум сайта python.su
Есть модель
# -*- coding: utf-8 -
from django.db import models
class sensor_type(models.Model):
measuring = models.CharField(max_length=30)#измеряемая величина
unit = models.CharField(max_length=30)#единица измерения
def __unicode__(self):
return self.measuring
class Meta:
ordering = ["measuring"]
class Admin:
pass
class measuring_datetime(models.Model):
datetime = models.DateTimeField(null=False)
def __unicode__(self):
return str(self.datetime)
class Meta:
ordering = ["datetime"]
class Admin:
pass
class measuring_value(models.Model):
datetime = models.ForeignKey(measuring_datetime, null=False)
sensor = models.ForeignKey(sensor_type, null=False)
value = models.FloatField(null=False)
def __unicode__(self):
return str(self.value)
class Meta:
ordering = ["value"]
class Admin:
pass
Офлайн
Офлайн