models.py 453 B

123456789101112131415
  1. from django.contrib.auth.models import User
  2. from django.db import models
  3. from django.db.models import Model
  4. from mptt.models import MPTTModel, TreeForeignKey
  5. # Create your models here.
  6. class Genre(MPTTModel):
  7. name = models.CharField(max_length=50, unique=True)
  8. parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children')
  9. class MPTTMeta:
  10. order_insertion_by = ['name']