Let's go nuts here ... From the inside of the shell I can do:
product.tags.add("a_new_tag")
The tag is added to db, and the tag association with the product works correctly. (ie when I do Product.objects.filter(tags__name__in=["a_new_tag"] , the corresponding product spits out)
What I need to do is add tags to the admin when processing the form.
Here is my form code (read the comments on lines 4 and 5):
class ProductForm(ModelForm): def save(self, commit=True): product = super(ProductForm, self).save(commit=False) product.type="New Type to Confirm Info is being Saved Correctly"
I tried to save in the admin class instead, but this does not work either:
class ProductAdmin(admin.ModelAdmin): form = ProductForm def save_model(self, request, obj, form, change): obj.type="new_type" //this works obj.tags.add("a_new_tag_2") //tag association not saved obj.save() form.save_m2m()
What am I doing wrong? Thanks in advance!
source share