Django 为CreateView声明另一个模板路径

Django 为CreateView声明另一个模板路径,django,django-models,django-forms,django-views,Django,Django Models,Django Forms,Django Views,我的django项目中有2个应用程序,1个。霍特拉普,2。管理酒店 使用HotelApp中的模型向用户显示酒店详细信息 但是,我在ManageHotels应用程序中设置了CreateView表单,供所有者添加酒店 问题是,CreateView试图在其中查找表单模板 HotelApp/templates/HotelApp/hotels\u forms.html 我宁愿将hotels_forms.html放在ManageHotels/templates/ManageHotels/hotels_for

我的django项目中有2个应用程序,1个。霍特拉普,2。管理酒店

使用HotelApp中的模型向用户显示酒店详细信息

但是,我在ManageHotels应用程序中设置了CreateView表单,供所有者添加酒店

问题是,CreateView试图在其中查找表单模板

HotelApp/templates/HotelApp/hotels\u forms.html

我宁愿将hotels_forms.html放在
ManageHotels/templates/ManageHotels/hotels_forms.html

如何更改模板路径


谢谢

您可以通过在CreateView上指定“模板名称”来指向所需的路径。比如:

class HotelCreate(CreateView):
template_name = 'ManageHotels/templates/ManageHotels/hotels_forms.html'
model = Hotel
fields = '__all__'

您必须相应地调整路径。更多信息,请访问

,您可以通过在CreateView上指定“模板名称”来指向所需的路径。比如:

class HotelCreate(CreateView):
template_name = 'ManageHotels/templates/ManageHotels/hotels_forms.html'
model = Hotel
fields = '__all__'
您必须相应地调整路径。更多关于这方面的信息,请访问