urls.py

       url(r'^accounts/register/$',register,
{'form_class':RegForm},name='registration_register'),

      form.py
      -------
      from registration.forms import *
      class RegForm(RegistrationForm):
          """
          """
          fullname = forms.RegexField(regex=r'^\w+$',
                                      max_length=30,
                                      widget=forms.TextInput
(attrs=attrs_dict),
                                      label=_(u'fullname'))
          def clean_fullname(self):
              "This function is required to overwrite an inherited
username clean"
              return self.cleaned_data['fullname']'''

         def clean(self):
                if not self.errors:
                  self.cleaned_data['first_name'] = '%s%s' %
(self.cleaned_data['fullname'].split(' ',1)[0])
                  self.cleaned_data['last_name'] = '%s%s' %
(self.cleaned_data['fullname'].split(' ',1)[1])
              super(RegForm, self).clean()
              return self.cleaned_data'''
      views.py
      --------
      def register(request, success_url=None,
                   form_class=RegForm, profile_callback=None,
                   template_name='registration/
registration_form.html',
                   extra_context=None):
          #pform_class = utils.get_profile_form()
          if request.method == 'POST':
              #profileform = pform_class(data=request.POST,
files=request.FILES)
              form = form_class(data=request.POST,
files=request.FILES)
              if form.is_valid():
                  new_user = form.save
(profile_callback=profile_callback)
                  #profile_obj = profileform.save(commit=False)
                  #profile_obj.user = new_user
                  #profile_obj.save()
                  return HttpResponseRedirect(success_url or reverse
('registration_complete'))
          else:
              form = form_class()
              #profileform = pform_class()
          if extra_context is None:
              extra_context = {}
          context = RequestContext(request)
          for key, value in extra_context.items():
              context[key] = callable(value) and value() or value
          return render_to_response(template_name,
                                    { 'form': form},
                                    context_instance=context)

      registration_form.html
      ----------------------
      <dl class="vertical">
                              <dt><label class="required"
for="fullname">Full Name</label></dt>
                              <dd>
                                  <div class="formHelp"></div>
                                  <div></div>
                                  {{ form.fullname }}
                                  {% for error in form.fullname.errors
%}
                                  <span style="color:red">{{ error }}</
span>
                                  {% endfor %}
                              </dd>
                              <dt><label class="required"
for="username">User Name</label></dt>
                              <dd>
                                  <div class="formHelp"></div>
                                  <div></div>
                                  {{ form.username }}
                                  {% for error in form.username.errors
%}
                                  <span style="color:red">{{ error }}</
span>
                                  {% endfor %}
                              </dd>
                             <dt><label class="required"
for="email">Email Address</label></dt>
                             <dd>
                                  <div class="formHelp"></div>
                                  <div></div>
                                  {{ form.email }}
                                  {% for error in form.email.errors %}
                                  <span style="color:red">{{ error }}</
span>
                                  {% endfor %}
                            </dd>
                             <dt><label for="password"
class="required">Password</label></dt>
                              <dd>
                                  <div class="formHelp"></div>
                                  <div></div>
                                  {{ form.password1 }}
                                  {% for error in
form.password1.errors %}
                                  <span style="color:red">{{ error }}</
span>
                                  {% endfor %}
                            </dd>
                             <dt><label for="confirm"
class="required">Confirm Password</label></dt>
                             <dd>
                                  <div class="formHelp"></div>
                                  <div></div>
                                  {{ form.password2 }}
                                  {% for error in
form.password2.errors %}
                                  <span style="color:red">{{ error }}</
span>
                                  {% endfor %}
                           </dd>
      While saving

      Full Name: |_____|   Enter a valid value.
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to