Django-taggit inserting -
my model defines 1 field like
keywords = taggablemanager(_('keywords'), blank=true)
from view need use get_or_create in for
*** transaction.commit_on_success(): # inserting obj_parsed defaults = { 'owner': user, 'title': obj.title, 'abstract': obj.abstract, #'keywords': [kw kw in obj.keywords], 'url': obj.url, } obj_instance, created = obj.objects.get_or_create( title=obj.title, defaults=defaults) if not created: result['error'] = _('url in repository') return result
obj.keywords list (it can empty) get_or_create gives me error "typeerror: 'keywords' invalid keyword argument function"
how can solve this?
i don't want do
mymodel = obj(**defaults) mymodel.save() mymodel.keywords.add([kw kw in obj.keywords])
thanks!
i had similar problem , looked taggit tests. thing got working adding tags after creation so:
defaults = { 'owner': user, 'title': obj.title, 'abstract': obj.abstract, 'url': obj.url, } obj_instance, created = obj.objects.get_or_create(title=obj.title, defaults=defaults) obj_instance.add(*obj.keywords)
Comments
Post a Comment