我正在尝试将views.py中的模块导入为
from django.shortcuts import render
# Create your views here.
from viewcreator import Builder
import json
def index(request):
a,b=Builder.buildChartJSON()
print(json.dumps(a))
print(json.dumps(b))
return render(request, 'hdfsStats/hdfscharts.html',
{'sourcepoints': a, 'sizepoints': b})
Run Code Online (Sandbox Code Playgroud)
这是我的项目设置的样子
为什么我不能在我的视图中导入模块?我不想在models.py中创建这些类.这些类只是为了运行一些计算并返回两个json对象,然后将其提供给我的网页
这是我的settings.py
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 1.9.4.
For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# …Run Code Online (Sandbox Code Playgroud)