Object needs to have a value for field "id" before this many-to-many relationship can be used in Django
django, django-models, django-related-manager, python
Solution
Your Declaration of
form.save_m2m()
should be after
obj.save()
After saving of object Many to Many field will add
Problem
I have the following code in my models.py: ``` class Tag(models.Model): name = models.CharField(max_length=75) class Article(models.Model): tags = models.ManyToManyField(Tag) def save(self, *args, **kwargs): for tag in self.tags: print tag.name super(Article, self).save(*args, **kwargs) ``` When I try to create an article from the admin panel, I get the following error: ``` ValueError: "<Article>" needs to have a value for field "id" before this many-to-many relationship can be used. ``` How can I fix this problem? I need to access and iterate the tags before saving the article. Thanks!