From: yomguy Date: Fri, 23 Nov 2012 14:13:22 +0000 (+0100) Subject: fix no course X-Git-Tag: 0.9-probarreau~303 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=a2739e7f3e4eb9b1a4bc615c7ce1bd996aaf42de;p=teleforma.git fix no course --- diff --git a/teleforma/management/commands/teleforma-import-professors.py b/teleforma/management/commands/teleforma-import-professors.py index a69bd9de..44536bf6 100644 --- a/teleforma/management/commands/teleforma-import-professors.py +++ b/teleforma/management/commands/teleforma-import-professors.py @@ -27,8 +27,9 @@ class Command(BaseCommand): p = Professor(user=user) p.save() for code in professor['courses']: - course = Course.objects.get(code=code) - p.courses.add(course) + course = Course.objects.filter(code=code) + if course: + p.courses.add(course[0]) print 'imported: ' + user.first_name + ' ' + user.last_name + ' ' + user.username def handle(self, *args, **options):