Created
October 6, 2017 00:42
-
-
Save jamesperes-zz/2d087391cebdb756dff97f711034bb3b to your computer and use it in GitHub Desktop.
erro de OO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TagGeral(models.Model): | |
tag = models.CharField(max_length=50, verbose_name='Tag secundarias') | |
class Post(models.Model): | |
tag = models.ManyToManyField(TagGeral) | |
tag_lista = models.CharField(max_length=100, blank=True) | |
def get_tags(self): | |
tags = self.tag_lista.split(', ') | |
tag_geral = TagGeral.objects.all() | |
for i in tags: | |
if tag_geral.filter(tag=i): | |
tag_filtered = tag_geral.get(tag__iexact=i) | |
self.tag.add(tag_filtered) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment