Graphs and tables for your Spotify account.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.3 KiB

  1. from django.db import models
  2. from django.contrib.postgres.fields import JSONField
  3. class Genre(models.Model):
  4. class Meta:
  5. verbose_name = "Genre"
  6. verbose_name_plural = "Genres"
  7. name = models.CharField()
  8. def __str__(self):
  9. return self.name
  10. class Artist(models.Model):
  11. class Meta:
  12. verbose_name = "Artist"
  13. verbose_name_plural = "Artists"
  14. name = models.CharField()
  15. genre = models.OneToOneField(Genre, on_delete=models.CASCADE)
  16. def __str__(self):
  17. return super(Artist, self).__str__()
  18. class AudioFeatures(models.Model):
  19. class Meta:
  20. verbose_name = "AudioFeatures"
  21. verbose_name_plural = "AudioFeatures"
  22. features = JSONField()
  23. def __str__(self):
  24. return self.features
  25. class Year(models.Model):
  26. class Meta:
  27. verbose_name = "Year"
  28. verbose_name_plural = "Years"
  29. year = models.PositiveSmallIntegerField()
  30. def __str__(self):
  31. return self.year
  32. class Track(models.Model):
  33. class Meta:
  34. verbose_name = "Track"
  35. verbose_name_plural = "Tracks"
  36. popularity = models.DecimalField(decimal_places=2)
  37. runtime = models.PositiveSmallIntegerField()
  38. name = models.CharField()
  39. def __str__(self):
  40. return self.name