Skip to content

Instantly share code, notes, and snippets.

@rmcauley rmcauley/blargh.py

Created Jan 31, 2020
Embed
What would you like to do?
class AlbumRating(models.Model):
album = models.ForeignKey(Album, models.CASCADE, db_index=False)
user = models.ForeignKey(User, models.CASCADE, db_index=False)
rating_complete = models.BooleanField(
blank=True, null=True, db_column="album_rating_complete"
)
rating_user = models.FloatField(
blank=True, null=True, db_column="album_rating_user"
)
station_id = models.SmallIntegerField(db_column="sid")
class Meta:
managed = False
db_table = "r4_album_ratings"
index_together = [("album", "user", "station_id"), ("album_id", "station_id")]
class AlbumOnStationQuerySet(models.QuerySet):
# TODO: possible to have with_rating here? (probably not...)
pass
class AlbumOnStationManager(models.Manager):
def get_queryset(self):
queryset = super().get_queryset()
queryset = queryset.select_related('album')
return queryset
class AlbumOnStation(models.Model):
album = models.ForeignKey(Album, models.CASCADE)
station_id = models.SmallIntegerField(db_column="sid", db_index=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.