This snippet allows to create user in django auth system without logging in. After this user logs in via Facebook account social user is created and bound to existing user.
Modelform cant inhertit from forms. To solve this issue, split thing you wanto to inherit into filed definition and functionality definition. For modelform use the base_fields.update method as mentioned in the code.
This is another fork of http://djangosnippets.org/snippets/2729/ that fixes the issue.
Unlike those other versions i give you instructions so it works for you, this is modified a little.
Instructions:
If you want to import the passwords from drupal you need to prepend to each of them the word drupal so it looks like this:
drupal$S$DQjyXl0F7gupCqleCuraCkQJTzC3qAourXB7LvpOHKx0YAfihiPC
Then add this snippet to someapp/hashers/DrupalPasswordHasher.py
And then in your settings add this:
PASSWORD_HASHERS = (
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
'someapp.hashers.DrupalPasswordHasher',
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
'django.contrib.auth.hashers.BCryptPasswordHasher',
'django.contrib.auth.hashers.SHA1PasswordHasher',
'django.contrib.auth.hashers.MD5PasswordHasher',
'django.contrib.auth.hashers.CryptPasswordHasher',
)
So, what did i modify
First i added the attribute algorithm to the class, django uses this word to identify wich hasher to use, so the passwords beggining with drupal should be verified with the hasher.algorithm == 'drupal'
Ok so know django knows to use our class, but now our passwords won't validate because we changed them by adding the word drupal, so what do we do? we modify the verify method to remove the word drupal before verification :P
Hope it helps
Theses two templatetags make easy to add an active class on a navigation link. The first one is based on a regexp an search if the request path match it. The second one simply use view names.
The version of [snippet](http://djangosnippets.org/snippets/2397/) that works with Django 1.5. Kudos to [kmike](http://djangosnippets.org/users/kmike/) for the original snippet.
An improvement to the excellent snippet by guettli [http://djangosnippets.org/snippets/2691/](http://djangosnippets.org/snippets/2691/)
Added support for cascading relations when using model inheritance.
A hack to add __in ability to links generated in the Django Admin Filter which will add and remove values instead of only allowing to filter a single value per field. Example ?age_group__in=under25%2C25-35
When work at site api for android client, I found use form to validate user input is too complex, so I write this.
usage:
@param('param_name', 'default_value', validate_func)
def api_func(request):
# access cleaned data.
param_name = request.DATA['param_name']
JsonResponse is my class. replace with HttpResponse or whatever