site_tps/content/models.py
2018-01-30 19:54:01 +01:00

35 lines
894 B
Python

from django.db import models
from django.urls import reverse
from django.contrib.auth.models import Group
class Category(models.Model):
"""Une catégorie de contenu."""
name = models.CharField(
max_length=255,
verbose_name="Nom de la catégorie"
)
def get_absolute_url(self):
return reverse('content:category-list', kwargs={'category_id':self.id})
class Content(models.Model):
"""Un contenu du site (vidéo)."""
name = models.CharField(
max_length=255,
verbose_name="Nom du contenu"
)
group_owner = models.ForeignKey(
Group,
on_delete=models.CASCADE,
)
content_url = models.URLField(
verbose_name='URL du contenu',
null=True,
)
category = models.ForeignKey(
Category,
on_delete=models.SET_NULL,
verbose_name="Catégorie",
null=True
)