Django: how can i assosiate multiple groups to one file?
I have a "File" table which could have multiple groups associated with it. How can i implement that with django?
groups = models.ForeignKey(Group)
This will enable me to only have one group for each file. I thought about creating a CharField with group names separated by 开发者_如何学Pythona colon or a comma if there's no other way.
Use many-to-many relationship
eg:
class File(models.Model):
...
class Group(models.Model):
files = models.ManyToManyField(File, related_name='groups')
精彩评论