我有一个名为 keykills 的模型。在这张表中,我想用逗号分割按键技能并将其一一存储。例子
userinput for keyskills = "django,python,html"
in database table(employerkeyskills)
id | emp_id | job_id | keyskills
----|----------|----------|------------
1 | 2 | 1 | django
2 | 2 | 1 | python
3 | 2 | 1 | html
模型.py
class User(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
username = models.CharField(max_length=100)
password = models.CharField(max_length=100)
class jobs(models.Model):
emp = models.ForeignKey(User, unique=False)
title = models.CharField(max_length=100)
referencecode = models.CharField(max_length=100)
jobsummary = models.TextField()
jobdetails = models.TextField()
class employerkeyskills(models.Model):
emp=models.ForeignKey(User,unique=False)
job=models.ForeignKey(jobs,unique=False)
keyskills=models.CharField(max_length=50)
在这里,我想通过逗号(,)拆分键技能,它从用户输入中获取并将其一个接一个地存储在 EMPLOYERKEYSKILLS 表中