如何從視圖中獲取初始值?我應該在表格中使用什麼參數?Django:從視圖的初始值
views.py
def cadastro_usuario(request):
if request.method == 'POST':
form = cadastroForm(request.POST)
if form.is_valid():
new_user = form.save()
return HttpResponseRedirect("/")
else:
form = cadastroForm()
return render_to_response("registration/registration.html", {
'form': form, 'tipo_cadastro': 'PF',})
forms.py
class cadastroForm(UserCreationForm):
tipo_cadastro = forms.CharField(XXXXX)
從視圖中獲取初始值? – Brandon
其實我需要在視圖中硬編碼一些變量,並將它們保存在UserProfile中(正如我向J. Landgrave解釋的) – Thomas