#views.py
def signup(request):
if request.method == "POST":
form = ProfileForm(request.POST)
if form.is_valid():
*new_user = Profile.objects.create_user(**form.cleaned_data)*
login(request, new_user)
return HttpResponse('signup success.')
else:
form = ProfileForm()
return render(request, 'registration/profile.html', {'form': form})
我想创建新的对象(对象),所以我想使用User.objects.create_user方法
#models.py
class Profile(models.Model):
studentNumber = models.CharField(max_length=30, blank=True)
name = models.CharField(max_length=10, blank=True)
major = models.CharField(max_length=20, blank=True)
email = models.CharField(max_length=30, blank=True)
password = models.CharField(max_length=15, blank=True)
phoneNumber = models.CharField(max_length=15, blank=True)
github = models.CharField(max_length=150, blank=True)
sns = models.CharField(max_length=150, blank=True)
这是我的模特! 如何将模型保存到数据库?