I want to make my home page as index.html
which is located inside the template directory named as templates/castle_tm/index.html
, but the url shows
"no module named simple".
Generic 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"}),
Imagine you need a static page or a listing page. Django offers an easy way to set those simple views that is called generic views. Unlike classic views, generic views are classes not functions.
The direct_to_template view certainly is useful, but Django’s generic views really shine when it comes to presenting views on your database content. Because it’s such a common task, Django comes with a handful of built-in generic views that make generating list and detail views of objects incredibly easy.
A base view for displaying a single object. It is not intended to be used directly, but rather as a parent class of the django.views.generic.detail.DetailView or other views representing details of a single object. This view inherits methods and attributes from the following views:
Because it’s such a common task, Django comes with a handful of built-in generic views that make generating list and detail views of objects incredibly easy. Let’s take a look at one of these generic views: the “object list” view.
In latest 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')),
I believe you're looking for a TemplateView
from django.views.generic import TemplateView
url(r'^api/casinova$', TemplateView.as_view(template_name="castle_tm/index.html")),
Generic based views have been replaced by class based generic views which allows you to override them easily to provide extra context data and reduce code repetition
For more information, Russell Keith-Magee did a very good presentation at djangocon a couple of years ago, you can watch it here - Class-based Views: Past, Present and Future
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With