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

  • Home
  • SEARCH
  • 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 6586425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:47:21+00:00 2026-05-25T16:47:21+00:00

I wrote a custom backend for my application to process logins in a sort-of

  • 0

I wrote a custom backend for my application to process logins in a sort-of unique way, as I have specific needs for this project. Here’s my backend:

from my.project.models import User 
from hashlib import sha512

class MyBackend:

    def authenticate(self, email_address=None, password=None):
        print "Trying to auth: " + email_address

        try: 
            user = User.objects.get(email_address=email_address)
            password = sha512(password + user.password_salt).hexdigest()

            if user.password != password:
                return None
            else:
                return user
        except User.DoesNotExist:
            return None

    def get_user(self, user_id):
        try:
            return User.objects.get(pk=user_id)
        except User.DoesNotExist:
            return None

Here’s my User class:

class User(models.Model):
    email_address = models.EmailAddressField()
    password = models.CharField(max_length=128)
    password_salt = models.CharField(max_length=128)

It’s pretty simple, but I’ve already built the rest of my models around this ‘User’ class.

Is there a way to make this work so as to have the best of both worlds, or should I ditch this approach and just use Django’s built-in model for users?

  • 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-25T16:47:22+00:00Added an answer on May 25, 2026 at 4:47 pm

    Extending the user can best be done by using user profiles.
    Define a user profile-model and at the bottom, add something like this:

    User.profile = property(lambda u: Profile.objects.get_or_create(user=u)[0])
    

    I think this approach might be better than replacing the User-model

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

Sidebar

Related Questions

I wrote a custom validation handler for this ASP.NET MVC application. Here is a
I have a client that is running a custom VB 6 application they wrote
I have rails application that connects to multiple databases. I wrote custom rake task
I have wrote a custom MultipleChoiceField. I have everything working ok but when I
I wrote my own custom namespace for a Spring based project I'm working on.
Ok, I created a windows control project....dropped a comboBox on it, wrote some custom
can anybody help me with this ? I have added some custom fields to
I wrote custom FxCop rules for our project. I wrote a wiki page documenting
I have a build problem with maven. I wrote a custom checkstyle check for
I wrote a custom web part for SharePoint 2007 that loads an existing user

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.