PlusDalaDrereMargrit
New Member
Okay, so I have this HTML form:\[code\]<form class="form" action="" method="post"> {% csrf_token %} {{ form.as_p }} <button type="submit" value="http://stackoverflow.com/questions/13703724/register">Login</button></form>\[/code\]And this Django view:\[code\]from django import formsfrom django.contrib.auth.forms import UserCreationFormfrom django.http import HttpResponseRedirectfrom django.shortcuts import render_to_responsefrom django.template import RequestContext def register(request): if request.method == 'POST': form = UserCreationForm(request.POST) if form.is_valid(): new_user = form.save() return HttpResponseRedirect("/success/") else: form = UserCreationForm() return render_to_response("signup.html", {'form': form,}, RequestContext(request))\[/code\]This works perfectly fine. But I want to be able to customize the original form a bit more. So, in order to try and figure out how to do that, I first look at the source code for the form.as_p function and try and replicate it manually. I end up with this:\[code\]<form class="form" action="" method="post"> {% csrf_token %} <p> <label for="id_username">Username:</label> <input id="id_username" type="text" name="username" maxlength="30"> </p> <p> <label for="id_password1">Password:</label> <input type="password" name="password1" id="id_password"> </p> <p> <label for="id_password2">Password confirmation:</label> <input type="password" name="password2" id="id_password2"> </p> <button type="submit" value="http://stackoverflow.com/questions/13703724/register">Login</button></form>\[/code\]However, this doesn't work. I can't understand why it doesn't. If form.as_p has the above as the output then it theoretically should work fine with the view shouldn't it? Any help would be appreciated.