def handle(self, *args, **options): u = Uva() for p in u.getProblems(): try: problem = Problem.objects.get(code=p['id'], judge='uva') except Problem.DoesNotExist: problem = Problem() problem.code = p['id'] problem.number = p['number'] problem.name = p['name'] problem.category = p['category'] problem.solved = p['solved'] problem.level = 0 problem.judge = 'uva' problem.save()
def handle(self, *args, **options): s = Spoj() problems = s.getProblems() for p in problems: try: problem = Problem.objects.get(code=p['code'], judge='spoj') except Problem.DoesNotExist: problem = Problem() problem.name = p['name'] problem.code = p['code'] problem.number = p['number'] problem.solved = p['solved'] problem.category = 'U' problem.level = 0 problem.judge = 'spoj' problem.save() print('%d problems.' % len(problems))