Skip to content

Instantly share code, notes, and snippets.

@ricomoss
Last active November 12, 2015 22:16
Show Gist options
  • Save ricomoss/86e7b9f5f5247b292240 to your computer and use it in GitHub Desktop.
Save ricomoss/86e7b9f5f5247b292240 to your computer and use it in GitHub Desktop.
# This is a bit messy
try:
program = student_schedule.zm_course.program
except AttributeError:
if program is None:
print("warning, could not add to class resource due to old model")
return
else:
program = program
if program is None:
print("warning, could not add to class resource due to old model")
return
# Replace above with:
if student_schedule.zm_course and student_schedule.zm_course.program:
program = student_schedule.zm_course.program
elif not program:
# This is an old model
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment