I have a model that stores URLs scraped from our group chat rooms at the office, I'd like to be able to move an object to an inherited model based on the url. I know inherited fields are simply a OneToOne relation, is there a simple way of of converting the object to inherited model? Here are the models in question:
class Link(models.Model):
url = models.URLField(max_length=2048, unique=True)
message = models.TextField()
room = models.ForeignKey(Room)
posted = models.DateTimeField()
def save(self, *args, **kwargs):
image_types = ['gif', 'jpg', 'jpeg', 'ico', 'png'. 'tiff', 'bmp']
if self.url.split('.')[-1] in image_types:
convert to ImageLink
super(Link, self).save(*args, **kwargs)
class ImageLink(Link):
pass