Opened 7 years ago

Last modified 7 years ago

#28942 closed Bug

ChoiceWidget.option_template_name ignores TEMPLATES DIRS — at Version 1

Reported by: Maksim Iakovlev Owned by: nobody
Component: Forms Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Maksim Iakovlev)

Django can only find template if it located in app dir (if path relative to BASE_DIR is myapp/templates/myapp/mytemplate.html), but raises TemplateDoesNotExist if template located in custom dir specified in TEMPLATES DIRS (if path relative to BASE_DIR is templates/myapp/mytemplate.html).

class MyWidget(ChoiceWidget):
    option_template_name = 'myapp/mytemplate.html'
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
            os.path.join(BASE_DIR, 'templates'),
        ],
        'APP_DIRS': True,
...

Change History (1)

comment:1 by Maksim Iakovlev, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top