fork download
  1. # encoding=utf-8
  2. class OdeskProfile(models.Model):
  3. title = models.CharField(max_length=255)
  4. skills = models.CharField(max_length=255)
  5. country = models.CharField(max_length=255)
  6. profile_id = models.CharField(max_length=255)
  7.  
  8. @classmethod
  9. def fill(cls):
  10. # Очевидно что считывание файла можно заменить на запрос в REST API.
  11. # и потом итерировать по json-массиву.
  12. with open('test.json') as data_file:
  13. data = json.load(data_file)
  14.  
  15. for item in data:
  16. profile = cls(**item)
  17. profile.save()
  18.  
  19. def __unicode__(self):
  20. return self.title
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError: Sorry: IndentationError: unexpected indent (prog.py, line 15)
stdout
Standard output is empty