What is the most simple solution to such a problem: use models.FileField for local file or models.CharField for entering URL, depends on an option which were switched before. The next code does not work, but shows the idea:
class T(models.Model):
action = models.ForeignKey(Action)
type = models.ForeignKey(Type)
if type == 2:
attachment = models.FileField(upload_to=settings.ATTACHEMENTS_FOLDER, blank=True, max_length=255)
else:
attachment = models.CharField(blank=True, max_length=255)
You should store it with in the
Type
model. That way it can be whatever field is correct. And you have flexibility of adding more types later.