Created
September 26, 2011 15:55
-
-
Save joshuatobin/1242563 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models.py | |
from django.db import models | |
from django.contrib.auth.models import User | |
from django.db.models.signals import post_save | |
class UserProfile(models.Model): | |
user = models.OneToOneField(User) | |
flip_databases = models.BooleanField() | |
def create_user_profile(sender, instance, created, **kwargs): | |
if created: | |
profile, created = UserProfile.objects.get_or_create(user=instance) | |
# User.profile = property(lambda u: UserProfile.objects.get_or_create(user=u)[0]) | |
post_save.connect(create_user_profile, sender=User) | |
# settings.py | |
AUTHENTICATION_BACKENDS = ( | |
'jinx_api.LdapRemoteUserBackend.LDAPRemoteUserBackend', | |
) | |
# ./manage.py shell | |
> from django.contrib.auth.admin import User | |
> u = User.objects.get(username='joshua') | |
> flip = u.get_profile().flip_databases | |
> flip = True | |
> user.save() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment