我无法在urls.py模块中导入views.py模块。 我尝试过多种方式,
from . import views
import views
from rango import views
但它们都不起作用,它只会引发import error
。
urls.py文件
错误: -
我能够在urls.py中导入models.py模块,但是无法在urls.py中导入views.py,即使models.py和views.py位于同一位置。
似乎神奇!!
答案 0 :(得分:2)
试试这个:
class BlogController < ApplicationController
before_action :load_posts
def index #this method puts all the stuff pulled from 'load_posts' and packages it nicely in a instanced variable
@blogPosts = BlogPost.all
end
def load_posts #this method should pull posts from AWS s3 and add them to the database (like magic)
end
end
我建议你阅读post
答案 1 :(得分:1)
我通常明确导入,例如:
from rango.views import add_category
但你可以试试
from rango import views