在views.py文件中引入models时,出现问题
from django.shortcuts import render from . import models def index(request): article = models.Article.objects.get(pk=1) context = {'hello': 'hello,man!'} return render(request, 'cmdb/index.html', context, {'acticle': article}m)
没有objects,说是无法导入,我的python版本是3.7,Django是2.1,pycharm是社区版,报的错误提示是:
his inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items.