Hi, I would like to get a list of tags separated by a comma and be able to save them as related objects for the current object. Currently I have this code. When saving a Receta object it creates the tags objects if they doesn't exist yet and it should save the relations between Tags and Receta, but they are not saved. The code doesn't give any errors but the Tag objects are not linked to the Receta object after saving it.
Any ideas why this happens? Thank you!!! class Tag(models.Model): nombre = models.CharField(maxlength=20) slug = models.SlugField(prepopulate_from=("nombre",),unique=True) class Receta(models.Model): user = models.ForeignKey(User) nombre = models.CharField(maxlength=50) slug = models.SlugField(prepopulate_from=("nombre",),unique=True) etiquetas = models.ManyToManyField(Tag,related_name='recetas',blank=True) tags_text = models.CharField(maxlength=150) def save(self): from django.template.defaultfilters import slugify tags = self.tags_text.split(',') super(Receta, self).save() etiquetas_new = [] for tag in tags: etiq, created = Tag.objects.get_or_create(nombre=tag,slug=slugify(tag)) etiquetas_new.append(etiq) self.etiquetas = etiquetas_new --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---