from uuid import uuid4

from django.db import models


class Genre(models.Model):
    """
    Book genre.

    """

    uuid = models.UUIDField(default=uuid4, db_index=True, verbose_name="UUID")
    code_name = models.CharField(max_length=64, blank=False, unique=True, verbose_name="code name")
    name = models.CharField(max_length=64, blank=False, verbose_name="name")
    description = models.TextField(blank=True, verbose_name="description")
    creation_date = models.DateTimeField(auto_now_add=True, verbose_name="creation date")

    class Meta:
        verbose_name = "genre"
        verbose_name_plural = "genres"

    def __str__(self):
        return f"{self.name}"
