Django:租户模板路径问题

我有一个应用程序,根据其类别,租户可以定向到位于/dashboard/templates/dashboard或 的应用程序(和模板) /dashboard2/templates/dashboard2。


不知何故,对于dashboard2,Django 找不到该应用程序,它尝试在dashboard.


这是仪表板2/views.py


@method_decorator(login_required, name='dispatch')

class SupplierPage2(LoginRequiredMixin,APIView):

    def get(self, request, *args, **kwargs):

        query = request.GET.get('search_ress', None)

        print(query)

        context = {}


        #if query and request.method == 'GET':

        Supplier = supplier2.objects.filter(supplier = query)

        print(Supplier)

       

        labels = Item2.objects.filter(fournisseur = query).values_list('reference', flat=True)[:10]

        print(labels)

        default_items = Item2.objects.filter(fournisseur = query).values_list('number_of_sales', flat=True)[:10]

        print(default_items)

        label1s = Item2.objects.filter(fournisseur = query).values_list('reference', flat=True)[:10]

        print(label1s)

        default_item1s = Item2.objects.filter(fournisseur = query).values_list('number_of_orders_placed', flat=True)[:10]

        print(default_item1s)

            

        context.update({'Supplier' : Supplier, 'labels':labels, 'default_items':default_items,'label1s':label1s, 'default_item1s':default_item1s})



        return render(request, 'Supplier2.html',context)

和错误:


TemplateDoesNotExist at /Supplier2.html

Supplier2.html

Request Method: GET

Request URL:    https://uname.website.net/Supplier2.html

Django Version: 3.0.5

Exception Type: TemplateDoesNotExist

Exception Value:    

Supplier2.html



qq_花开花谢_0
浏览 101回答 1
1回答

哆啦的时光机

修复设置如下:TEMPLATES = [    {        'BACKEND': 'django.template.backends.django.DjangoTemplates',        'DIRS': [os.path.join(BASE_DIR, "dashboard/templates/dashboard"), os.path.join(BASE_DIR,"dashboard2/templates/dashboard2")],        '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',                'django.template.context_processors.i18n'            ],        },    },]
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python