I have 3 Models:
class FileType(models.Model):
name=models.CharField(max_length=128)
class ManagedFile(models.Model):
type = models.ForeignKey(FileType)
content = models.FileField(upload_to=path_maker)
class Tag(models.Model):
type = models.ForeignKey(FileType)
m_file = models.ForeignKey(ManagedFile)
def clean(self):
if self.m_file is None:
return
if self.type != self.m_file.type:
raise ValidationError("File type does not match Tag type")
When select an m_file for a tag, the m_files type MUST match the Tags type. This is all well and good, but the admin drop down for Tag.m_file shows files of all types, regardless of the Tag's type. This is Confusing to users.
There seem to me a number of ways to filter the drop down statically. So if I wanted to say that we will never let the user see Type.pk=1 in the dropdown, I can to that. But there does not seem to be a way to filter on m_file.Type == Self.Type