diff --git a/docs/installation.rst b/docs/installation.rst index c335f219..6b834992 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -102,25 +102,25 @@ Be sure to run manage.py syncdb after setting this up. Otherwise Django Facebook provides an abstract model which you can inherit like this:: -from django.db import models -from django.dispatch.dispatcher import receiver -from django_facebook.models import FacebookModel -from django.db.models.signals import post_save -from django_facebook.utils import get_user_model, get_profile_model -from your_project import settings - - -class MyCustomProfile(FacebookModel): - user = models.OneToOneField(settings.AUTH_USER_MODEL) - -@receiver(post_save) -def create_profile(sender, instance, created, **kwargs): - """Create a matching profile whenever a user object is created.""" - if sender == get_user_model(): - user = instance - profile_model = get_profile_model() - if profile_model == MyCustomProfile and created: - profile, new = MyCustomProfile.objects.get_or_create(user=instance) + from django.db import models + from django.dispatch.dispatcher import receiver + from django_facebook.models import FacebookModel + from django.db.models.signals import post_save + from django_facebook.utils import get_user_model, get_profile_model + from your_project import settings + + + class MyCustomProfile(FacebookModel): + user = models.OneToOneField(settings.AUTH_USER_MODEL) + + @receiver(post_save) + def create_profile(sender, instance, created, **kwargs): + """Create a matching profile whenever a user object is created.""" + if sender == get_user_model(): + user = instance + profile_model = get_profile_model() + if profile_model == MyCustomProfile and created: + profile, new = MyCustomProfile.objects.get_or_create(user=instance) Remember to update AUTH_PROFILE_MODULE in settings to your new profile. Don't forget to update your database using syncdb or south after this step. @@ -135,3 +135,4 @@ If you encounter any difficulties please open an issue. Of course you now want to customize things like the login button, the page after registration etc. This is explained in the integration section. +