Which is equivalent to django.views.generic.simple import direct_to_template in django 1.9

I want my homepage to be index.html , which is inside the template directory named templates/castle_tm/index.html , but the URL shows

"no module named simple".

General view based views are deprecated in django> 1.4. Now how can I redirect the home page to index.html

urls.py

 from django.conf.urls import url, patterns, include from django.conf.urls.static import static from django.conf import settings from django.contrib import admin from castle import views from django.views.generic.simple import direct_to_template admin.autodiscover() url(r'^api/casinova$', direct_to_template,{"template":"castle_tm/index.html"}), 
+7
python django
source share
2 answers

In recent versions of django you can use TemplateView

 from django.views.generic import TemplateView ... url(r'^api/casinova$', TemplateView.as_view(template_name='castle_tm/index.html')), 
+11
source share

I believe you are looking for a TemplateView

 from django.views.generic import TemplateView url(r'^api/casinova$', TemplateView.as_view(template_name="castle_tm/index.html")), 

Views based on the general view have been replaced by generic class-based views, which makes it easy to redefine them to provide additional context data and reduce code repetition

For more information, Russell Keith-Magee made a very good presentation at djangocon a couple of years ago, you can watch it here - Class-based Views: Past, Present and Future

+6
source share

All Articles