Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed formatting issue in installation.rst #492

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.