Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9153137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:12:58+00:00 2026-06-17T12:12:58+00:00

I’m trying to extend Django registration to include my own registration form. In principle

  • 0

I’m trying to extend Django registration to include my own registration form. In principle this is fairly simple. I just have to write my own form (CustomRegistrationForm) which is a child of the original one (RegistrationForm). Then I can process my specific input by using the user_registered signal of django registration.

So here is what I did:

urls.py:

from django.conf.urls import patterns, include, url
from registration.views import register
from forms import CustomRegistrationForm
from django.contrib import admin
import regbackend
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^register/$', register, {'backend': 'registration.backends.default.DefaultBackend', 'form_class': CustomRegistrationForm, 'template_name': 'custom_profile/registration_form.html'}, 
                        name='registration_register'),
)

regbackend.py:

from django import forms
from models import UserProfile
from forms import CustomRegistrationForm

def user_created(sender, user, request, **kwargs):
    form = CustomRegistrationForm(data=request.POST, files=request.FILES)
    if form.is_valid(): # HERE: always fails
        user_profile = UserProfile()
        user_profile.user = user
        user_profile.matriculation_number = form.cleaned_data['matriculation_number']
        user_profile.save()

from registration.signals import user_registered
user_registered.connect(user_created)

forms.py:

from models import UserProfile
from django import forms
from registration.forms import RegistrationForm
from django.utils.translation import ugettext_lazy as _

attrs_dict = {'class': 'required'}

class CustomRegistrationForm(RegistrationForm):
    matriculation_number = forms.CharField(widget=forms.TextInput(attrs=attrs_dict),
                                           label=_("Matriculation number"),
                                           max_length=12,
                                           error_messages={'invalid': _("This value has to be unique and may contain only numbers.")},
                                           initial=108)

    def clean_matriculation_number(self):
        print "Validating matriculation number."
        data = self.cleaned_data['matriculation_number']
        if len(data) != 12:
            raise forms.ValidationError(_("Matriculation number consists of exactly 12 digits."))
        return data

So the problem is the is_valid() function, because it always returns False. Even if there are no errors! So what is wrong? I spent hours on this one and I have no idea anymore 🙁

Any help is much appreciated!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:12:59+00:00Added an answer on June 17, 2026 at 12:12 pm

    Ok I think I solved it (more or less).

    I’m still not really sure, why the form did not validate. But as I said I was extending django-registration and the ‘register’ view already called is_valid() of the form, so I can assume that the form is valid when I process the posted data any futher. The view then calls the backend

    backend.register(request, **form.cleaned_data)
    

    with the request and the cleaned data (which is just username, email and password). So I can’t use it for registration because my additional information is missing. The backend then fires the signal that I am using and what I did is, is that I created the form again with the provided request. This form, however, will NOT validate (and I tried everything!!) I looked it up, I am doing the exact same thing as django-registration, but it’s not working in my code.

    So I did not really solve the problem, because the form is still not validating. But I found peace with this, when I realized that the form was already validated by the ‘register’ view. So I am using form.data[..] instead of form.cleaned_data[..] now which shouldn’t be a problem…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.