Skip to content

Instantly share code, notes, and snippets.

@gileno
Created May 5, 2012 14:36
Show Gist options
  • Save gileno/2602936 to your computer and use it in GitHub Desktop.
Save gileno/2602936 to your computer and use it in GitHub Desktop.
Uso do Select Extra
alternatives = Alternative.objects.filter(exercise=exercise)
select_sql = u'''select courses_solveexercise.response
from courses_solveexercise where
courses_solveexercise.user_id=%s and
courses_solveexercise.alternative_id=courses_alternative.id'''
alternatives = alternatives.extra(select=SortedDict([('user_response', select_sql)]),
select_params=[user.id])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment