Open korvinos opened 7 years ago
I created a simple function in views which import models from geospass project:
from django.http import HttpResponse
import os, sys os.environ['DJANGO_SETTINGS_MODULE'] = 'geospaas_project.settings' sys.path.insert(0, '/vagrant/shared/course_vm/geospaas_project/') # import django django.setup() # from django.conf import settings from geospaas.catalog.models import Dataset
def read_data(request):
ds = Dataset.objects.filter(source__instrument__short_name='MODIS')
output = '; '.join([str(d.time_coverage_start) for d in ds])
return HttpResponse(output)
So I am getting an error when try to import models from geo-spaas project, something like this
RuntimeError Traceback (most recent call last)
I solved by adding to th installed apps the following:
'
INSTALLED_APPS = [ 'geospaas.catalog',
# BEGIN ANSIBLE MANAGED BLOCK geospaas.vocabularies
'geospaas.vocabularies',
'geospass_fun',
'blog.apps.BlogConfig', ....
So
ds = Dataset.objects.filter(sourceinstrumentshort_name='MODIS')
works, but output = '; '.join([str(d.time_coverage_start) for d in ds])
gives the error: OperationalError: no such table: catalog_dataset
We are going to keep all business logic in a view function (so far)