djangosnippets.org: Latest snippets tagged with 'username'http://djangosnippets.org/tags/username/2016-01-04T08:42:03.576173-06:00Email authentication backend
2016-01-04T08:42:03.576173-06:00benjaominghttp://djangosnippets.org/snippets/10547/<p>Fixed minimal version, works with Django 1.7+, tested on Django 1.9.</p>
<p>Add the following to your settings:</p>
<pre><code>AUTHENTICATION_BACKENDS = [
'project.backends.UserModelEmailBackend', # Login w/ email
'django.contrib.auth.backends.ModelBackend', # Login w/ username
]
</code></pre>
Freely redistributableShortcut for smart printing user's full name or username in template
2010-07-19T17:19:07.079364-05:00rudyrykhttp://djangosnippets.org/snippets/2115/<p><code>{{ user|nice_name }}</code></p>
<p>is the same as</p>
<p><code>{{ user.get_full_name|default:user.username }}</code></p>
Freely redistributableUsername filled automatically with id
2010-01-14T14:44:34.987314-06:00djangomanhttp://djangosnippets.org/snippets/1867/<p>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 ).</p>
<p>Let me know what you think about this snippet and if you advice an alternative solution …</p>
Freely redistributableUsernameField (for clean error messages)
2009-08-06T18:31:36.551669-05:00davepeckhttp://djangosnippets.org/snippets/1673/<p>This is a username field that matches (and slightly tightens) the constraints on usernames in Django's <code>User</code> model. </p>
<p>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.</p>
Freely redistributableUsername form field
2008-11-16T04:33:48.268755-06:00smahttp://djangosnippets.org/snippets/1196/<p>Use a <code>UserField</code> 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.</p>
<p>Example:</p>
<pre><code>class Book(models.Model):
owner = models.ForeignKey(User) …</code></pre>
Freely redistributableUsername genrator
2008-04-24T22:13:10.021660-05:00gustavo80brhttp://djangosnippets.org/snippets/723/<p>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 …</p>
Freely redistributableUsing dojo/json to check for username availability
2007-06-21T11:03:09.017487-05:00heckjhttp://djangosnippets.org/snippets/292/<p>An example of using Dojo to retrieve some information from a view (linked by the URL '/account/isavailable/') to show whether or not an account is available.</p>
Freely redistributable