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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:53:07+00:00 2026-05-25T19:53:07+00:00

In my registration, a user can create an account with no password if they

  • 0

In my registration, a user can create an account with no password if they wish. I would like the password field in a login form to be optional.

I am currently using the built in view django.contrib.auth.views.login for logins. The form validation in this requires a password to be submitted.

Is it possible to customize/override the built in form to allow passwords to be submitted optionally, if so how? Obviously it will still validate a login where both a username and password is provided and the user has set a password at registration.

Thanks

  • 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-25T19:53:08+00:00Added an answer on May 25, 2026 at 7:53 pm

    Thanks @Alasdair that was a great help. I discovered I did not need to write a custom authentication backend. Full solution is below for anyone else who might need it:

    #forms.py
    from django.contrib.auth.forms import AuthenticationForm
    from django.contrib.auth import authenticate
    from django.utils.translation import ugettext_lazy as _
    
    class LoginForm(AuthenticationForm):
        username = forms.CharField(max_length=30)
        password = forms.CharField(widget=forms.PasswordInput, required=False)
        user_cache = None
    
        def clean(self):
            try:
                username = User.objects.get(username=self.cleaned_data['username']).username
            except User.DoesNotExist:
                raise forms.ValidationError(_("No such user registered."))
    
            self.user_cache = authenticate(username=username, password=self.cleaned_data['password'])
            if self.user_cache is None or not self.user_cache.is_active:
                raise forms.ValidationError(_("Username or password is incorrect."))
            return self.cleaned_data
    
        def get_user(self):
            return self.user_cache
    
    #urls.py
    from myapp.forms import LoginForm
    
    urlpatterns = patterns('',
        ...
        url(r'^login/$', 'django.contrib.auth.views.login', {'authentication_form': LoginForm}),
        ...
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to create a user registration form where the user ticks some boxes
I want to put 2 fields on user registration form, /customer/account/create/. Those fields are
I have a user registration Form. If a new User register their account in
I want to create a simple user registration form with First / Last name,
Summary of the question: I would like to create a CakePHP based registration and
I have to do a user registration form (classical layout with two columns, labels
I'm currently implementing a user registration for an app. I'm tying to change the
I want to make a user-registration form where I will have fields such first
I am creating an user registration form using jsp,in which there is an option
I'm trying to create a User Registration page in ASP.NET and wondering what is

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.