Hi Again, Here is what we used to get around the email restriction. It works very well for authenticating through your application, Admin is a different story. In our case the users who register online never need to log into admin. If yours do, then you will have to strip logic from several files.
In /django/contrib/auth/backends.py modify the following function.... def authenticate(self, **credentials): try: user = None if 'username' in credentials: user = User.objects.get(username=credentials ['username']) else: user = User.objects.get(email=credentials['email']) if user.check_password(credentials['password']): return user except User.DoesNotExist: return None Then when authenticating all you have to do is use: user = authenticate(email=email, password=password) or you can fall back on... user = authenticate(username=email, password=password) Either way thats all it takes, works like a charm now. There was even a patch for this many months back, too bad Django developers went the exact opposite way... http://code.djangoproject.com/ticket/7591 Should we re-open the ticket? Either way, if you want email authentication leave feedback... -Paul On Apr 7, 10:16 am, pkenjora <pkenj...@gmail.com> wrote: > Hi, > > Why not remove the '@' filter and allow the specific project > developer the freedom to use email as username? What was the > reasoning behind this? > > I always like Django because it didn't try to force development down > a specific path. All developers have their own way and every project > is unique, for a long time Django accommodated that. I'm a bit > worried about where this is going... > > I'm worried that the workarounds just introduce unnecessary > complexity. We are currently upgrading to Django 1.02 and will most > likely strip the limiting logic instead of working around it. I will > have a patch available for anyone interested later today. > > - Paul > > On Apr 2, 7:11 pm, Malcolm Tredinnick <malc...@pointy-stick.com> > wrote: > > > On Thu, 2009-04-02 at 19:04 -0700, Timboy wrote: > > > What's the best way to add users with an auto generating username? ie: > > > Taub.John, Smith.Tim, Smith.Tim2 > > > You can do it however you like, since the user will never see it. > > Something as simple as taking the email address, replacing "@" with "AT" > > and "." with "DOT" might work. > > > One thing I did for a client was take the email address, trip off > > everything after the "@" and then continue adding a number to the end of > > the username until it was unique. So if t...@example.com registered > > first, he would be username "tim" and t...@foo.bar.org would be username > > "tim1", since "tim" was already in use. Since all registration is > > normally done through one or two places, it only required setting up the > > registration form handling view and writing a management command tool to > > add a user manually. These days, I might also add some admin overrides, > > but I didn't need that at the time. > > > Regards, > > Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@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 -~----------~----~----~----~------~----~------~--~---