We don't have your UserCreationForm, but usually those things have
password1 and password2 fields, and no "password"
On Thursday, December 17, 2015 at 10:16:33 PM UTC+1, Dariusz Mysior wrote:
>
> I have this view and I have a bug why?
>
> def index(request):
> # jezeli formularz coś wysłał
> if request.method == 'POST':
> form_r = UserCreationForm(request.POST)
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
>
> # jezeli uzytkownik istnieje
> if user is not None:
> if user.is_active:
> login(request, user)
> return HttpResponseRedirect('profile')
>
> else:
> # Return a 'disabled account' error message
> ...
> else:
> # Return an 'invalid login' error message.
> return HttpResponseRedirect('invalid_login')
> if form_r.is_valid():
> form_r.save()
> info="Zarejestrowałeś się!"
> return render_to_response('ownsite/register_success.html',
> {info:'info'})
> else:
> return HttpResponseRedirect('/')
> # tworze formularze
> args = {}
> args.update(csrf(request))
> args['form_l'] = AuthenticationForm()
> args['form_r']= UserCreationForm()
>
> return render_to_response('index.html', args)
>
>
> A bug
>
>
> MultiValueDictKeyError at /
>>
>> "'password'"
>>
>> Request Method: POST Request URL: http://127.0.0.1:8000/ Django Version:
>> 1.8.4 Exception Type: MultiValueDictKeyError Exception Value:
>>
>> "'password'"
>>
>> Exception Location:
>> C:\Python34\lib\site-packages\django\utils\datastructures.py
>> in __getitem__, line 322 Python Executable: C:\Python34\python.exe Python
>> Version: 3.4.3 Python Path:
>>
>> ['C:\\Python34\\ownsite',
>> 'C:\\WINDOWS\\SYSTEM32\\python34.zip',
>> 'C:\\Python34\\DLLs',
>> 'C:\\Python34\\lib',
>> 'C:\\Python34',
>> 'C:\\Python34\\lib\\site-packages']
>>
>> Server time: Czw, 17 Gru 2015 22:07:11 +0100
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/cd361b1d-5916-4ac7-adec-45ca9cf39c67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.