What is the most efficient way to store a list in the Django models?
django, django-models, python
Solution
Would this relationship not be better expressed as a one-to-many foreign key relationship to a `Friends` table? I understand that `myFriends` are just strings but I would think that a better design would be to create a `Friend` model and have `MyClass` contain a foreign key realtionship to the resulting table.
Problem
Currently I have a lot of python objects in my code similar to the following: ``` class MyClass(): def __init__(self, name, friends): self.myName = name self.myFriends = [str(x) for x in friends] ``` Now I want to turn this into a Django model, where self.myName is a string field, and self.myFriends is a list of strings. ``` from django.db import models class myDjangoModelClass(): myName = models.CharField(max_length=64) myFriends = ??? # what goes here? ``` Since the list is such a common data structure in python, I sort of expected there to be a Django model field for it. I know I can use a ManyToMany or OneToMany relationship, but I was hoping to avoid that extra indirection in the code. Edit: I added this related question, which people may find useful.