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 909159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:49:54+00:00 2026-05-15T16:49:54+00:00

I have found here on stackoverflow a method to extend django’s built-in authentication using

  • 0

I have found here on stackoverflow a method to extend django’s built-in authentication using signals. My base User is defined by ’email’ and passwords (so no username there). So I’m trying to modify it to my needs, but I’m geting a validation error for my form. Strange thing is that error is connected to the User.email field and I’m getting ‘already in use’ even though I’m just registering at the moment. Is it trying to save it 2 times or what ? I’ve discovered it when I was sending dictionary with data to form’s contstructor in shell: form = MyForm(data={}). After this form was still invalid, but changing email to different value finally gave me True.

The user_created function connected to registration signal :

def user_created(sender, user, request, **kwargs):
    form = CustomRegistrationForm(request.POST, request.FILES)
    if form.is_valid():
        data = UserProfile(user=user)
        data.is_active = False
        data.first_name = form.cleaned_data['first_name']
        data.last_name = form.cleaned_data['last_name']
        data.street = form.cleaned_data['street']
        data.city = form.cleaned_data['city']
        data.save()
    else:
        return render_to_response('user/data_operations/error.html', {'errors': form._errors}, context_instance=RequestContext(request))

user_registered.connect(user_created)

My form :

class CustomRegistrationForm(RegistrationForm):
    first_name = forms.CharField(widget=forms.TextInput(attrs=attrs_dict), max_length=50)
    last_name = forms.CharField(widget=forms.TextInput(attrs=attrs_dict), max_length=50)
    street = forms.CharField(widget=forms.TextInput(attrs=attrs_dict), max_length=50)
    city = forms.CharField(widget=forms.TextInput(attrs=attrs_dict), max_length=50)

My model :

class UserProfile(models.Model):
    first_name = models.CharField(_("Name"), max_length=50, blank=False,)
    last_name = models.CharField(_("Last name"), max_length=50, blank=False,)
    street = models.CharField(_("Street"), max_length=50, blank=False,)
    city = models.CharField(_("City"), max_length=50, blank=False,) 
    user = models.ForeignKey(User, unique=True, related_name='profile',)

Registration form :
class RegistrationForm(forms.Form):

email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
                                                           maxlength=75)),
                         label=_("Adres email"))
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
                            label=_("Haslo"))
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
                            label=_("Haslo powtorzone"))

def clean_email(self):
    email = self.cleaned_data.get("email")
    if email and User.objects.filter(email=email).count() > 0:
        raise forms.ValidationError(
            _(u"Already in use."))
    return email
  • 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-05-15T16:49:54+00:00Added an answer on May 15, 2026 at 4:49 pm

    your ‘user_registered’ signal is sent after the User is saved. So it already has an ’email’ field defined.

    UPDATE


    Using restless thinking :

    form = CustomRegistrationForm(request.POST, request.FILES, notvalidateemail=True)
    

    and in form :

    def __init__(self, *args, **kwargs):
        self.notvalidateemail = kwargs.pop('notvalidateemail',False)
        super(CustomRegistrationForm, self).__init__(*args, **kwargs)
    
    def clean_email(self):
        if self.notvalidateemail:
            return
        else:
            #your cleaning here
            return email
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Here is an XSLT 1.0 stylesheet that will do what… May 16, 2026 at 5:55 pm
  • Editorial Team
    Editorial Team added an answer First of all, use new-style classes (ones that inherit from… May 16, 2026 at 5:55 pm
  • Editorial Team
    Editorial Team added an answer What you are doing is a bit like building a… May 16, 2026 at 5:55 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have two classes: Action class, that has a method for executing VBScript files,
After searching stackoverflow.com I found several questions asking how to remove duplicates, but none
Update In the wiki spirit of StackOverflow, here's an update: I spiked Joe White's
We build software using Hudson and Maven. We have C#, java and last, but
I have searched Google and Stackoverflow for this question, but I still don't understand
After stackoverflow answered my previous question on here about my Wiimote left/right click issue,
I want to set up a Mercurial SC server and have been following the
I have tried to find the answer to this question on both the Spring
I'm having problems binding on a form with multiple models being submitted. I have
On my CMS I have a list of thumbnails (Sortable). The thumbnails work great

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.