test/apps/gto/models/model_indicators.py

32 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
from django.db import models
from django.urls import \
reverse # Used to generate URLs by reversing the URL patterns
from apps.gto.models.model_sensors import Sensors
class Indicators(models.Model): # Датчики
sensor = models.ForeignKey(
Sensors, on_delete=models.SET_NULL, null=True, verbose_name="Сенсор"
)
time = models.DateTimeField(
auto_now=False, auto_now_add=False, blank=True, verbose_name="Время показания"
)
value = models.FloatField(default=0.0, help_text="", verbose_name="Значение")
def __str__(self):
"""
String for representing the Model object (in Admin site etc.)
"""
return self.sensor.name
class Meta: # отображение в админики
verbose_name = "gказания датчика"
verbose_name_plural = "показания датчиков"
indexes = [
models.Index(fields=["sensor"]),
models.Index(fields=["sensor", "time"]),
]