antingshen/BeaverDam

find annotation of videos

sujiez opened this issue · 3 comments

Hi Beaverdam development team,

I need your help to access annotations of videos in a python code. I remember that I can access those annotations through the shell by doing:

from annotator.models import Video
Video.objects.all()

However, when I put the first line in my py file which is in the same folder as manage.py, I get such error:

Traceback (most recent call last):
File "try.py", line 1, in
from annotator.models import Video
File "/home/szhou/BeaverDam/annotator/models.py", line 22
def from_list(cls, path_to_list, *, source, host, filename_prefix=''):
                       ^
SyntaxError: invalid syntax

Could you help me to solve this problem? Thanks.

Seems like you're using the wrong Python version. Ensure it's Python 3.4+

This error shows when I am using python2.7, but when I switch to python3.5, I get such error (attached as screen shot)
screenshot from 2017-08-08 11-35-36

I think the problem is solved, and there are some good solution when you google "access django models from outside". Basically, I just put these line of codes before my file:

import os
from django.core.wsgi import get_wsgi_application
os.environ['DJANGO_SETTINGS_MODULE'] = "beaverdam.settings"
application = get_wsgi_application()

Thanks to you guys, we can have such a good annotation tool.