import uuid from django.db import models # Create your models here. from django.urls import reverse class DroughtSpi(models.Model): id = models.UUIDField('id', primary_key=True, default=uuid.uuid4()) code = models.CharField('区站号', max_length=256, null=False) year = models.IntegerField('年份', null=True, blank=True) month = models.IntegerField('月份', null=True, blank=True) value = models.FloatField('值') added = models.DateTimeField(auto_now_add=True,null=True,blank=True) updated = models.DateTimeField(auto_now=True,null=True,blank=True) def get_absolute_url(self): return reverse('data-spi-detail', kwargs={'pk': self.pk}) def __str__(self): return self.code