我在此路径上有一个模板ais/demo/testapp/athlete/acruds/create.html
我认为它是正确的,但错误是
/ testapp / athlete / create的TemplateDoesNotExist testapp / athlete / acruds / create.html,acruds / create.html
为什么路径以逗号分隔错误?和 我仍然遇到这个问题
我的form.py
是
class AthleteForm(forms.ModelForm):
class Meta:
model = Athlete
fields = '__all__'
def __init__(self, *args, **kwargs):
super(AthleteForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_tag = False
self.helper.layout = Layout(
Tab(
_('Basic information'),
Field('name', wrapper_class="col-md-6"),
Field('image', wrapper_class="col-md-6"),
)
)
self.helper.layout.append(
FormActions(
Submit('submit', _('Submit'), css_class='btn btn-primary'),
HTML("""{% load i18n %}<a class="btn btn-danger"
href="{{ url_delete }}">{% trans 'Delete' %}</a>"""),
)
)
我的view.py文件是
class AthleteCRUD(CRUDView):
model = Athlete
template_name_base = 'acruds' # customer cruds => ccruds
namespace = None
check_login = True
check_perms = True
views_available = ['create']
fields = ['name', 'image']
# related_fields = ['invoice']
custom_forms = {
'add_': AthleteForm,
# 'update_customer': CustomerForm,
# 'add_addresses': AddressesForm,
# 'update_addresses': AddressesForm,
}
modelforms = custom_forms
和模板路径的绝对路径如下
/home/user/Desktop/ais/django-cruds-adminlte/demo/demo/templates/testapp/athlete/acrud/create.html