Login

Tag "username"

Snippet List

Email authentication backend

Fixed minimal version, works with Django 1.7+, tested on Django 1.9. Add the following to your settings: AUTHENTICATION_BACKENDS = [ 'project.backends.UserModelEmailBackend', # Login w/ email 'django.contrib.auth.backends.ModelBackend', # Login w/ username ]

  • authentication
  • email
  • auth
  • username
  • backend
Read More

Username filled automatically with id

I thought this code for insert automatically id in username field. This method should be used in save method. This code work on a dbms that support transactions ( example: mysql+innodb or postgresql ). Let me know what you think about this snippet and if you advice an alternative solution by commenting below. Thanks :)

  • username
  • id
  • transaction
Read More

UsernameField (for clean error messages)

This is a username field that matches (and slightly tightens) the constraints on usernames in Django's `User` model. Most people use RegexField, which is totally fine -- but it can't provide the fine-grained and user friendly messages that come from this field.

  • fields
  • forms
  • user
  • auth
  • form
  • field
  • username
  • users
  • authorization
Read More

Username form field

Use a `UserField` if you want to replace the usual select menu with a simple input field that only accepts valid user names. Should be easy to generalize for other models by passing a query set and the attribute name that represents the instance. Example: class Book(models.Model): owner = models.ForeignKey(User) class BookForm(forms.ModelForm): owner = UserField() class Meta: model = Book

  • user
  • form
  • field
  • username
  • textual
Read More
Author: sma
  • 1
  • 2

Username genrator

This function generate an username based on the user's full name. First it tries to use the first name first letter plus the last name, second it tires the first name plus the last name first latter, and at last it tries to use the first name with a sequential number at the end. The username generated are all lowercase and ASCII only characters.

  • auth
  • username
  • name
Read More

7 snippets posted so far.