It is not possible to have a DictField because the underlying database does not support this type of data structure.
You may have a RelationshipScore model for storing your relationships and a ForeignKey from it to the existing model (I will use the user as an example). eg:
Class RelationshipScore(models.Model): user = models.ForeignKey(User) relationship = models.CharField(max_length=50, primary_key=True) score = models.IntegerField()
Then you can add functions to the existing model to get the values:
class User(models.Model): def get_relationship(self, rel): return RelationshipScore.objects.get(relationship=rel, user=self) def get_lowest_relationship(self): return RelationshipScore.objects.filter(user=self).order_by("-score")[0]
source share