【发布时间】:2020-10-26 08:18:20
【问题描述】:
这是我的models.py
class Profile(models.Model):
idno=models.AutoField(primary_key=True)
name=models.CharField(max_length=30)
email=models.CharField(max_length=40)
choices = (
('C', 'C'),
('C++', 'C++'),
('Java', 'Java'),
('Python', 'Python'),
)
intrest = models.CharField(max_length=6, choices=choices)
marks=models.IntegerField(default=0)
这是我的观点,我要求用户选择他们的兴趣
def timeline(request):
intrest=Profile.objects.all()[0].intrest
if intrest =='':
if request.method=="POST":
choice=request.POST['choice']
print(choice)
profile=Profile(intrest=choice)
profile.save()
此代码正在创建一个名称和电子邮件为空白的新配置文件,如何将当前信息保存给同一用户?
【问题讨论】:
标签: django django-models django-views django-forms