in django 1.7, i'm unable provide custom template. instead defaults django_tables2/table.html
from django_tables2 import table basetable class table(basetable): class meta: template = 'portal/base_table.html'
and folder structure:
apps/portal/ ├── __init__.py ├── tables.py ├── templates │ └── portal │ ├── base.html │ ├── base_portal.html │ ├── base_table.html │ └── home.html
in above, templates such portal/base.html
resolved template finders.
if forego meta class , instead set:
from django_tables2 import table basetable class table(basetable): template = 'portal/base_table.html'
i instead error templatedoesnotexist
seems trying resolve /data/www/apps/portal/templates/no template names provided
among others.
to further support think template should resolving:
>>> render_to_response('portal/base_table.html') <django.http.response.httpresponse object @ 0x7fa940c74690> >>> render_to_response('portal/base_table.html2') ... raise templatedoesnotexist(name) templatedoesnotexist: portal/base_table.html2
my settings.py
file contains:
base_dir = os.path.dirname(os.path.dirname(__file__)) path = lambda *a: os.path.join(base_dir, *a) template_dirs = ( path('templates'), )
this working other templates such views. django-tables2 not use same lookup method?
in django tables2, using custom template providing custom template, need render in templates this:
<div class=""> {% load render_table django_tables2 %} {% render_table table 'portal/base_table.html'%} </div>
you can check answer reference: is possible apply template tag <td> when using django-tables2?
Comments
Post a Comment