I have a model for storing music and it has last_queried_at field that is used for deleting the music object if not queried for a month.
class CustomManager(models.Manager):
use_in_migrations = True
def get_queryset(self):
queryset = super().get_queryset()
queryset.update(last_queried_at=timezone.now())
return queryset
class Music(models.Model):
file = models.FileField(upload_to="music/")
created_at = models.DateTimeField(auto_now_add=True)
last_queried_at = models.DateTimeField(auto_now=True)
user = models.ForeignKey(
User,
models.SET_NULL,
null=True,
blank=True,
related_name="music",
)
objects = CustomManager()
When I try to make migrations it throws an error
django.db.utils.ProgrammingError: relation "app_music" does not exist
LINE 1: UPDATE "app_music" SET "last_queried_at" = '2...
I would appreciate if anyone could help me figure out how to solve this problem
I tried to use django's makemigrations command and threw an error. I was expecting it to create migrations.