Commit 7eebea97 authored by Ilya Simonov's avatar Ilya Simonov

add category for video

parent c6c0adc3
......@@ -18,5 +18,10 @@ class PlayListAdmin(admin.ModelAdmin):
readonly_fields = ['created', 'updated']
class CategoryAdmin(admin.ModelAdmin):
list_display = ['id', 'name', ]
admin.site.register(models.Video, VideoAdmin)
admin.site.register(models.Playlist, PlayListAdmin)
admin.site.register(models.Category, CategoryAdmin)
# Generated by Django 4.1.7 on 2023-03-06 13:56
# Generated by Django 4.1.7 on 2023-03-06 14:07
import apps.core.utils
from django.conf import settings
......@@ -15,6 +15,13 @@ class Migration(migrations.Migration):
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(db_index=True, max_length=255, verbose_name='name')),
],
),
migrations.AddField(
model_name='video',
name='closed_captions',
......@@ -80,4 +87,9 @@ class Migration(migrations.Migration):
'ordering': ('title',),
},
),
migrations.AddField(
model_name='video',
name='categories',
field=models.ManyToManyField(blank=True, related_name='video', to='core.category', verbose_name='categories'),
),
]
......@@ -27,6 +27,13 @@ class BaseModel(models.Model):
abstract = True
class Category(models.Model):
name = models.CharField('name', max_length=255, db_index=True)
def __str__(self):
return self.name
class Video(BaseModel):
title = models.CharField(_('title'), max_length=255)
slug = models.SlugField(_('slug'), max_length=255, unique=True, blank=True)
......@@ -72,6 +79,12 @@ class Video(BaseModel):
blank=True,
null=True,
)
categories = models.ManyToManyField(
Category,
verbose_name='categories',
related_name='video',
blank=True,
)
class Meta:
ordering = ('title',)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment