Changed Image model path to method.

This commit is contained in:
Miguel Astor
2026-03-24 15:39:09 -04:00
parent 5ec793b47d
commit 13ab55d1d3
2 changed files with 24 additions and 1 deletions

View File

@@ -11,13 +11,17 @@ from django.db.models import (
)
def get_gallery_root():
return settings.GALLERY_ROOT
class Image(Model):
"""
User relations to a specific image file by path.
"""
user = ForeignKey(settings.AUTH_USER_MODEL, blank=False, null=False, on_delete=CASCADE)
path = FilePathField(path=settings.GALLERY_ROOT, blank=False, null=False)
path = FilePathField(path=get_gallery_root, blank=False, null=False)
favorite = BooleanField(blank=False, null=False, default=False)
last_visited = DateTimeField(blank=False, null=False, default=timezone.now)
visits = IntegerField(blank=False, null=False, default=0)