Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to customize UserRegistration Form of Django?
    text
    copied!<p>I want to know how to change the display of default UserRegistrationForm. This is my views.py file.</p> <pre><code>from django.http import * from django.shortcuts import render_to_response from django.http import HttpResponseRedirect from django.contrib import auth from django.core.context_processors import csrf from django.contrib.auth.forms import UserCreationForm from forms import MyRegistrationForm def register_user(request): if request.method == 'POST': form = MyRegistrationForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/accounts/register_success') args = {} args.update(csrf(request)) args['form'] = MyRegistrationForm() return render_to_response('register.html', args) def register_success(request): return render_to_response('register_success.html') </code></pre> <p>This is what is displayed in templates of register_user.</p> <pre><code>{% extends "application/base.html" %} {% block content %} &lt;h2&gt; Register &lt;/h2&gt; &lt;form action="/accounts/register/" method="post"&gt;{% csrf_token %} {{form}} &lt;input type="submit" value="Register" /&gt; &lt;/form&gt; {% endblock %} </code></pre> <p>I want to access each and every filed of the {{form}} independently so that the it is easy to access the view.how to do it??</p> <p>Also this is my forms.py file</p> <pre><code>from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm class MyRegistrationForm(UserCreationForm): email = forms.EmailField(required=True) class Meta: model = User fields = ('username', 'email', 'password1', 'password2') def save(self,commit=True): user=super(MyRegistrationForm, self).save(commit=False) user.email=self.cleaned_data['email'] if commit: user.save() return user </code></pre> <p>Please Help me i am new to django??</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload