python - Multiple Objects Returned (Profiles) while creating Account on Mezzanine Project -


i've got working mezzanine (with pybb) setup in local environment. pybb got abstract profile class define user attributes , ships profile class in case you're not using 1 already.

everything working except signup process ends in creating user, resulting in following traceback:

http://pastebin.com/mfubpc2a

i thought pybbmiddleware issue. (how creating 2 profiles?)

class pybbmiddleware(object):      def process_request(self, request):          if request.user.is_authenticated():              try:                 # here try load profile, can error                 # if user created during syncdb profile model                 # under south control. (like pybb.profile).                 profile = request.user.get_profile()             except objectdoesnotexist:                 # ok, should create new profile user                 # , grant permissions add posts                 user_saved(request.user, created=true)                 profile = request.user.get_profile()              language = translation.get_language_from_request(request)              if not profile.language:                 profile.language = language                 profile.save()              if profile.language , profile.language != language:                 request.session['django_language'] = profile.language                 translation.activate(profile.language)                 request.language_code = translation.get_language() 

the user_saved() in pybb's signals.py:

def user_saved(instance, created, **kwargs):     if not created:         return     try:         add_post_permission = permission.objects.get_by_natural_key('add_post', 'pybb', 'post')         add_topic_permission = permission.objects.get_by_natural_key('add_topic', 'pybb', 'topic')     except objectdoesnotexist:         return     instance.user_permissions.add(add_post_permission, add_topic_permission)     instance.save()     if settings.auth_profile_module == 'pybb.profile':         models import profile         profile(user=instance).save() 

and on top of i've got user_saved() in accounts/models.py:

@receiver(post_save, sender=user) def user_saved(sender=none, instance=none, **kwargs):     profile.objects.get_or_create(**{str(user_field): instance}) 

is calling both , creating 2 profiles?

thanks help!

i suspect using mezzanine.accounts , have auth_profile_module set in settings.py. code in mezzanine.accounts.models sets signal when user model saved profile generated. i'm running same issue when creating user , profile in using tastypie.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -