I have to create get_absolute_url from an input given into a manytomanyfield.
Here is the relevant model.
class ConnectTag(models.Models):
whitetags = models.ManyToManyField(Tag, related_name='whitectags')
name = models.CharField(max_length=20, blank=True)
user = models.ForeignField(User, related_name='directconnecttags')
detail = models.TextField(blank=True)
def get_absolute_url:
return "%s.%s.%s...." %tag1,%tag2 ,%tagn
where tag1,tag2,tag3 are whitetags. How do I rewrite the last line into actual code ?
Not entirely clear what you’re asking, but this might help:
where
fieldnameis the field name on the Tag model which you want to output.