Login

Snippets by benjaoming

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

Bootstrap button dropdown widget (replaces forms.Select)

You need jQuery and Bootstrap 2 and bootstrap-dropdown.js. Apart from that, this should be a perfect drop-in replacement for the normal select widget. A jQuery event callback maintains a hidden input field from the user's selection. Upon loading the page, the hidden input field is set. The SelectWidgetBootstrap also contains a <noscript> tag containing the normal forms.Select widget. Example usage: class MyForm(forms.Form): group = forms.ModelChoiceField(models.Group.objects.all(), widget=SelectWidgetBootstrap(), empty_label=_(u'(no group selected)'))

  • dropdown
  • select
  • bootstrap
Read More

benjaoming has posted 2 snippets.