Skip to content

Instantly share code, notes, and snippets.

@andres-torres-marroquin
Created May 2, 2012 19:29
Show Gist options
  • Save andres-torres-marroquin/2579558 to your computer and use it in GitHub Desktop.
Save andres-torres-marroquin/2579558 to your computer and use it in GitHub Desktop.
def get_profile(user):
if not hasattr(user, '_profile_cache'):
profile, created = UserProfile.objects.get_or_create(user=user)
user._profile_cache = profile
return user._profile_cache
User.get_profile = get_profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment