1
0
Fork 0

Added slug in database (needs db sync)

This commit is contained in:
Shgck 2015-05-02 13:06:39 +02:00
parent cb7bd7201f
commit 68df3de4a7
2 changed files with 15 additions and 5 deletions

View file

@ -2,5 +2,9 @@ from django.contrib import admin
from label.models import *
admin.site.register(Artist)
admin.site.register(Release)
class ArtistAdmin(admin.ModelAdmin):
exclude = ("slug",)
admin.site.register(Artist, ArtistAdmin)
admin.site.register(Release)

View file

@ -1,4 +1,5 @@
from django.db import models
from django.template.defaultfilters import slugify
class Artist(models.Model):
@ -9,6 +10,7 @@ class Artist(models.Model):
image: image file associated with this project
"""
name = models.CharField(max_length = 64)
slug = models.SlugField()
image = models.ImageField(upload_to = "artists")
url_bandcamp = models.URLField(blank = True)
url_soundcloud = models.URLField(blank = True)
@ -18,10 +20,16 @@ class Artist(models.Model):
def __str__(self):
return self.name
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)
class Meta(object):
ordering = ("name",)
rel_types_hint = "full-length (0), EP (1), Split (2), Démo (3)"
class Release(models.Model):
""" A release (album, EP, ...) of the label.
@ -35,13 +43,11 @@ class Release(models.Model):
release_type: see below
year: year of release
cover: image file associated to this release
Release types: full-length (0), EP (1), Split (2), Démo (3)
"""
ident = models.IntegerField()
title = models.CharField(max_length = 256)
contributors = models.ManyToManyField(Artist)
release_type = models.IntegerField(default = 0)
release_type = models.IntegerField(default = 0, help_text = rel_types_hint)
cover = models.ImageField(upload_to = "releases")
year = models.IntegerField()
embed = models.TextField(blank = True)