django-select2/tests/testapp/models.py
2015-03-29 22:32:19 +02:00

42 lines
1 KiB
Python

# -*- coding:utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class Genre(models.Model):
title = models.CharField(max_length=50)
def __str__(self):
return self.title
@python_2_unicode_compatible
class Artist(models.Model):
title = models.CharField(max_length=50)
genres = models.ManyToManyField(Genre)
def __str__(self):
return self.title
@python_2_unicode_compatible
class Album(models.Model):
title = models.CharField(max_length=255)
artist = models.ForeignKey(Artist)
def __str__(self):
return self.title
@python_2_unicode_compatible
class Song(models.Model):
title = models.CharField(max_length=255)
album = models.ForeignKey(Album, blank=True, null=True)
artist = models.ForeignKey(Artist)
genres = models.ManyToManyField(Genre, blank=True, null=True)
def __str__(self):
return self.title