from django.db import models from gallery.models import Album class Redir(models.Model): path = models.CharField(max_length=255, db_index=True, unique=True, verbose_name="Path") album = models.ForeignKey(Album, on_delete=models.CASCADE, related_name='pathurl', verbose_name="Album") class Meta: verbose_name_plural = "Redirs" def __str__(self): return '{0} - {1}'.format(self.path, self.album.slug)