@receiver(post_save, sender=UserLog)
def cull_records(sender, **kwargs):
 if (settings.USER_LOG_MAX_RECORDS_PER_USER and kwargs['created']):
  current_models = UserLog.objects.filter(user=kwargs['instance'].user, activity_type=kwargs['instance'].activity_type)
  if (current_models.count() > settings.USER_LOG_MAX_RECORDS_PER_USER):
   to_discard = current_models.order_by('start_datetime')[0:(current_models.count() - settings.USER_LOG_MAX_RECORDS_PER_USER)]
   UserLog.objects.filter(pk__in=to_discard).delete()

@ receiver ( post_save , sender = UserLog ) def cull_records ( sender , ** kwargs ) : if ( settings . USER_LOG_MAX_RECORDS_PER_USER and kwargs [ 'created' ] ) : current_models = UserLog . objects . filter ( user = kwargs [ 'instance' ] . user , activity_type = kwargs [ 'instance' ] . activity_type ) if ( current_models . count ( ) > settings . USER_LOG_MAX_RECORDS_PER_USER ) : to_discard = current_models . order_by ( 'start_datetime' ) [ 0 : ( current_models . count ( ) - settings . USER_LOG_MAX_RECORDS_PER_USER ) ] UserLog . objects . filter ( pk__in = to_discard ) . delete ( )
listen in to see when videos become available .