From 2f9956756e88fe35c0d20a8625bf3ff6c2199458 Mon Sep 17 00:00:00 2001 From: Dece Date: Thu, 17 Aug 2017 19:13:54 +0200 Subject: [PATCH] Add VideoClip model --- label/admin.py | 3 ++- label/migrations/0002_videoclip.py | 29 +++++++++++++++++++++++++++++ label/models.py | 15 +++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 label/migrations/0002_videoclip.py diff --git a/label/admin.py b/label/admin.py index be877eb..c8b4347 100644 --- a/label/admin.py +++ b/label/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from label.models import Artist, Release +from label.models import Artist, Release, VideoClip class ArtistAdmin(admin.ModelAdmin): @@ -9,3 +9,4 @@ class ArtistAdmin(admin.ModelAdmin): admin.site.register(Artist, ArtistAdmin) admin.site.register(Release) +admin.site.register(VideoClip) diff --git a/label/migrations/0002_videoclip.py b/label/migrations/0002_videoclip.py new file mode 100644 index 0000000..3ce902c --- /dev/null +++ b/label/migrations/0002_videoclip.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2017-08-17 17:12 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('label', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='VideoClip', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=256)), + ('year', models.IntegerField()), + ('embed', models.TextField()), + ('artist', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='videos', to='label.Artist')), + ], + options={ + 'ordering': ('year', 'title'), + }, + ), + ] diff --git a/label/models.py b/label/models.py index 96369bc..7f3bddd 100644 --- a/label/models.py +++ b/label/models.py @@ -64,3 +64,18 @@ class Release(models.Model): class Meta(object): ordering = ('ident', 'title') + + +class VideoClip(models.Model): + """ A video clip. """ + + title = models.CharField(max_length=256) + artist = models.ForeignKey(Artist, related_name='videos') + year = models.IntegerField() + embed = models.TextField() + + def __str__(self): + return self.title + + class Meta(object): + ordering = ('year', 'title')