<s> from django . db . models . signals import post_save <EOL> from django . dispatch import receiver <EOL> from django . contrib . auth . models import User <EOL> from django . contrib . auth . signals import user_logged_in <EOL> from . models import UserProfile <EOL> @ receiver ( post_save , sender = User ) <EOL> def create_user_profile ( sender , instance , created , ** kwargs ) : <EOL> if created : <EOL> UserProfile . objects . create ( user = instance ) <EOL> @ receiver ( user_logged_in ) <EOL> def set_user_lang ( sender , request , user , ** kwargs ) : <EOL> try : <EOL> profile = user . get_profile ( ) <EOL> if profile . language : <EOL> request . session [ '<STR_LIT>' ] = profile . language <EOL> if profile . timezone : <EOL> request . session [ '<STR_LIT>' ] = profile . timezone <EOL> except UserProfile . DoesNotExist : <EOL> pass </s>
