Created
January 31, 2020 02:48
-
-
Save rmcauley/4e7397f7b2ac977c2c850045d5813d35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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