0
from django.shortcuts import render

from .models import Destination
# Create your views here.
def index(request):
    dest1 = Destination.objects.all()
    return render(request,"index.html",{'dest1':dest1})

错误:从 .models 导入目的地 ImportError:无法从“travellor.models”导入名称“目的地”(C:\Users\Raja Kumar\projects\telusko\travellor\models.py)

谁能帮我吗 ?

4

2 回答 2

0

错误发生在from .models import Destination. 基本上是说models.py模块中没有这样的模型。

于 2020-06-06T14:36:56.393 回答
0

您正在尝试从当前应用导入模型,但该模型不存在。

对于外部导入,您需要在模型之前指向应用程序

from destination.models import Destination

destination如果不同,请更改为您的应用程序的名称

于 2020-06-06T14:37:26.460 回答