Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python TemplateDoesNotExist at/accounts/(带颤振的Django)_Python_Django_Flutter_Server - Fatal编程技术网

Python TemplateDoesNotExist at/accounts/(带颤振的Django)

Python TemplateDoesNotExist at/accounts/(带颤振的Django),python,django,flutter,server,Python,Django,Flutter,Server,我正试图把弗利特和德扬戈联系起来。只有弗拉特和德扬戈似乎很好,工作没有错误。但当我试图将两者结合在一起时,会弹出一个错误,上面写着: TemplateDoesNotExister位于/帐户/ 下面是问题的原因 from django.shortcuts import render, HttpResponse def home(request): return render(request, '../screens/login_screen.dart') 它说目录不存在 正如您在上

我正试图把弗利特和德扬戈联系起来。只有弗拉特和德扬戈似乎很好,工作没有错误。但当我试图将两者结合在一起时,会弹出一个错误,上面写着:

TemplateDoesNotExister位于/帐户/

下面是问题的原因

from django.shortcuts import render, HttpResponse


def home(request):
    return render(request, '../screens/login_screen.dart')
它说目录不存在

正如您在上面看到的,目录存在。有什么问题吗?有人能帮忙吗

模板:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

我能看到的是screens文件夹在根目录上,但不在accounts文件夹内,它是自己的。 为此,您必须在设置中的模板配置中明确提及。您必须提到“BASE_DIR,‘模板所在文件夹的名称’”。这里是如何写的

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,'screens')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
其次,您必须以这种方式在视图中给出文件的路径

    return render(request, 'screens/login_screen.dart', context)


希望对您有所帮助。

您能在设置文件中显示模板配置吗。@MuhammedMahir我更新了问题。您现在可以看到了。