0
我有以下型號:ManyToManyField在Django
class Position(models.Model):
label = models.CharField(max_length=100)
class UserProfile(models.Model):
location = models.CharField(max_length=100, blank=True)
positions = models.ManyToManyField(Position)
我將如何正確輸入下面的兩個語句?
-- UserpProfile.objects.create(location = 'usa', positions = 'artist')
-- UserProfile.objects.create(location = 'usa', positions = 'artist', 'programmer', and 'teacher')
注意:我不想提供值供用戶選擇。我只希望他們能夠輸入多個職位,然後在表格中存儲這些職位。