37956-vm/core/models.py
2026-01-30 14:09:03 +00:00

23 lines
1.0 KiB
Python

from django.db import models
class Station(models.Model):
name = models.CharField(max_length=100)
stream_url = models.URLField(help_text="URL for the radio stream")
metadata_api_url = models.URLField(blank=True, null=True, help_text="Optional API URL to fetch current track metadata")
description = models.TextField(blank=True)
color = models.CharField(max_length=7, default="#FF007F", help_text="Hex color for the vinyl")
image = models.FileField(upload_to="stations/", blank=True, null=True)
is_active = models.BooleanField(default=True)
def __str__(self):
return self.name
class Track(models.Model):
station = models.ForeignKey(Station, related_name="tracks", on_delete=models.CASCADE)
title = models.CharField(max_length=200)
artist = models.CharField(max_length=200)
audio_file = models.FileField(upload_to="tracks/", blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"{self.artist} - {self.title}"