i wanted to create a tag option for a a music model , well mainly musics accept more than one tag and there are amny kind of genres and tags ,so i wanted to make a ManyToManyField()
that you can set more than 1 value ,also if you tag is not in add it in. to do that i thought maybe can make another CharField()
then adding it to tag_name
:
#posts model name = models.CharField(max_length=200) band = models.CharField(max_length=200) release = models.DateTimeField() tag_add = models.CharField(max_length=100) tags = models.ManyToManyField(Tags) #cover = models.ImageField(upload_to='media/image') #file = models.FileField(upload_to='media/audio') class Meta(self): ordering = ['release'] def __str__(self): return self.name def get_absolute_url(self): return reverse('pages:music_detail',args=[str(self.id)]) class Tags(models.Model): tag_name = models.CharField(max_length=100)
but i stuck here too ,i really dont know how to add a models field data to another models field ? i would appreciate if you guide me here
Advertisement
Answer
For a user to select more than one tag, they simply have to ctrl
then click on the tags. For Android I suppose it’s long-pressing.
For adding a tag if it’s not in the models, you don’t need a field for that. In the admin, you can just click on the +
sign.