I have a text area input on a simple HTML page, where I am posting comma-separated keywords to save into my database table.
For example,
Keywords input is like: keyword1,keyword2,keyword3, ...
I am using Django 3.2 and Tastypie as a API framework.
Here is my Django model:
class Keywords(models.Model):
keyword = models.CharField(max_length=200, unique=True)
class Meta:
db_table = 'keywords'
And Tastypie resource:
class KeywordResource(ModelResource):
class Meta(CommonMeta):
queryset = Keywords.objects.all()
resource_name = 'keyword-resource'
filtering = {'id': ALL, 'keyword': ALL}
allowed_methods = ['get', 'post', 'put', 'patch']
I want to save the comma-separated keyword in one post request from the client side. How can I post comma-separated keywords and insert them one by one into the table Keywords?
Also, what would be the best way to use save() method from model or hydrate() method from tastypie resource to prepare the data to save?

you can override the
hydrateand theobj_createmethod