from django.db import models
from django.utils import timezone


class oplog(models.Model):
    create_time = models.DateTimeField('创建时间', default=timezone.now)
    update_time = models.DateTimeField('更新时间', auto_now=True)
    content = models.TextField('日志内容', max_length=2000)

    class Meta:
        verbose_name = '运维日志'
        verbose_name_plural = verbose_name
        ordering = ['-create_time']
        db_table = 'oplog'

    def __str__(self):
        return f"{self.create_time.strftime('%Y-%m-%d %H:%M')} - {self.content[:50]}"
