Closed engrimran7 closed 2 years ago
So just to confirm, you're getting the following error? 'list' object has no attribute 'pk'
yes i am getting the following error 'list' object has no attribute 'pk'
Any expert here please assist to resolve the issue if possible to resolve. or point the mistake in my code if any.
Apologies for the delay - this project is open source and although there are several regular contributors, it only has one unpaid maintainer, so please bear that in mind regarding my availability to offer support.
I suspect this line:
instance.Tags.add(mylist)
should be this:
instance.Tags.add(*mylist)
I haven't tested this in a while, but looking at the code that should be supported. Let me know if you still get the error.
1st of all i apologies for my premature knowledge in coding
@radiac Thanks a lot for your time and the fix you provided
instance.Tags.add(*mylist)
by using above error #41 is fixed but the tags are not getting listed in tags field. i even tested with print output method to check if out put is coming correctly or not, output is ok but the tag field remains empty after saving the post by post save signal.
is it possible to achieve the same by pre insert the tags and then post save.
now i am getting below error if i use Pre_save instead of post save because post save is not not adding tags to the field or even to the db
ValueError at /admin/firmApp/resource/add/ "<resource: check>" needs to be saved before TagField can use the database
Hi i tried to copy fields like (title,model,brand,varient,size,) to the tags automatically instead of adding the same again manually
i tried below code and it throughs an error which is already discussed here #41 but it dint helped at all.
class resource(models.Model): title=models.CharField(max_length=100) size=models.CharField( max_length=20, default="") desc=models.TextField(default="") file=models.FileField(default="", blank=True) url= models.URLField(max_length=200, blank=True) Brand = models.ForeignKey(brand,on_delete=models.CASCADE, default="") Model = models.ForeignKey(model,on_delete=models.CASCADE, default="") Categories = models.ForeignKey(category,on_delete=models.CASCADE, default="") update_at=models.DateField(auto_now=True) slug=models.SlugField(max_length=200, null=True,blank=True) Tags = tagulous.models.TagField( to=Skill, help_text="This field does not split on spaces" )
def tag_set(sender, instance,*arg, **kwargs): ans= array_tag(instance) mylist = ["firmware", "download", "gsm"] instance.Tags.add(mylist)
post_save.connect(tag_set, sender=resource)
any quick fix will be highly appreciated