我已经按照文档中的说明创建了我的 UserProfile 模型,但是如何传递要从我的视图中保存的值。这就是我的观点:
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid():
now = timezone.now()
user = User.objects.create(
username = form.cleaned_data['username'],
first_name = form.cleaned_data['username'],
last_name = form.cleaned_data['username'],
email = form.cleaned_data['email'],
is_staff = False,
is_active = False,
is_superuser = False,
last_login = now,
date_joined = now
)
user.set_password(form.cleaned_data['password'])
user.save()