view videos/models.py @ 205:b4566292bbfe tip

Update t-shirt inventory
author Brian Neal <bgneal@gmail.com>
date Sun, 06 Nov 2022 17:42:25 -0600
parents e2868ad47a1e
children
line wrap: on
line source
"""
Models for the videos application.

"""
from django.db import models


class Collection(models.Model):
    """
    This model represents a collection of videos.

    """
    title = models.CharField(max_length=64)
    description = models.TextField()
    date_added = models.DateTimeField()

    class Meta:
        ordering = ['-date_added']

    def __unicode__(self):
        return self.title

    @models.permalink
    def get_absolute_url(self):
        return ('videos-item', [], {'pk': str(self.id)})


class Video(models.Model):
    """
    This model represents a video clip hosted on a remote video sharing site
    (e.g. YouTube).

    """
    title = models.CharField(max_length=64)
    embed_code = models.TextField()
    collection = models.ForeignKey(Collection)

    class Meta:
        ordering = ['title']

    def __unicode__(self):
        return self.title