Skip to content

Commit

Permalink
set default template on view instead of renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Feb 2, 2017
1 parent c067d33 commit 73e92fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion rest_pandas/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def get_output(self):
class PandasHTMLRenderer(TemplateHTMLRenderer, PandasBaseRenderer):
media_type = "text/html"
format = "html"
template_name = "rest_pandas.html"

def render(self, data, accepted_media_type=None, renderer_context=None):
table = PandasBaseRenderer.render(
Expand Down
5 changes: 5 additions & 0 deletions rest_pandas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
SimpleSerializer, PandasSerializer
)

DEFAULT_TEMPLATE = False
PANDAS_RENDERERS = getattr(settings, "PANDAS_RENDERERS", None)
if PANDAS_RENDERERS is None:
PANDAS_RENDERERS = (
Expand All @@ -23,6 +24,7 @@
"rest_pandas.renderers.PandasSVGRenderer",
)
if "rest_pandas" in settings.INSTALLED_APPS:
DEFAULT_TEMPLATE = True
PANDAS_RENDERERS = (
"rest_pandas.renderers.PandasHTMLRenderer",
) + PANDAS_RENDERERS
Expand All @@ -36,6 +38,9 @@ class PandasMixin(object):

pagination_class = None

if DEFAULT_TEMPLATE:
template_name = 'rest_pandas.html'

def with_list_serializer(self, cls):
meta = getattr(cls, 'Meta', object)
if getattr(meta, 'list_serializer_class', None):
Expand Down

0 comments on commit 73e92fd

Please sign in to comment.