from django db import models from tagging fields import TagField from

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from django.db import models
from tagging.fields import TagField
from tagging.models import Tag
# Create your models here.
class Twit(models.Model):
artist = models.CharField(max_length=150)
album = models.CharField(max_length=200)
cover = models.CharField(max_length=250, blank=True)
duration = models.IntegerField(blank=True, null=True)
bitrate = models.IntegerField(blank=True, null=True)
user = models.CharField(max_length=200)
url = models.CharField(max_length=250)
year = models.CharField(max_length=4,null=True, blank=True)
tags = TagField()
twit_id = models.DecimalField(max_digits=14, decimal_places=0)
created_at = models.DateTimeField(auto_now_add=True)
modered = models.BooleanField()
deleted = models.BooleanField()
def set_tags(self, tags):
Tag.objects.update_tags(self, tags)
def get_tags(self):
return Tag.objects.get_for_object(self)
def get_tracks(self):
return Track.objects.filter(twit__id=self.id)
class Track(models.Model):
artist = models.CharField(max_length=150)
album = models.CharField(max_length=200)
name = models.CharField(blank=True, max_length=100)
duration = models.IntegerField(blank=True, null=True)
twit = models.ForeignKey(Twit)