django design model
I'm trying to design model in Django.
I want that App can link to many languages, and from admin site when I create new app be able to select more then one language.
class Language(models.Model):
name = models.CharField(max_length=20)
code = m开发者_Python百科odels.CharField(max_length=6)
def __unicode__(self):
return self.name
class App(models.Model):
name = models.CharField(max_length=50)
pub_date = models.DateTimeField()
languages = ?
How should I write it ?
languages = ManyToManyField(Language)
http://docs.djangoproject.com/en/dev/ref/models/fields/#manytomanyfield is the relevant part of the Django docs you may find useful
精彩评论