Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No module named simple" error in Django

Tags:

django

ImportError at / No module named simple  Django Version: 1.5.dev20120710212642 

I installed latest django version. I am using

from django.views.generic.simple import redirect_to 

in my urls.py. What is wrong? Is it deprecated?

like image 728
Burak Avatar asked Jul 11 '12 08:07

Burak


1 Answers

Use class-based views instead of redirect_to as these function-based generic views have been deprecated.

Here is simple example of class-based views usage

from django.conf.urls import patterns, url, include from django.views.generic import TemplateView  urlpatterns = patterns('',     (r'^about/', TemplateView.as_view(template_name="about.html")), ) 

Update

If someone wants to redirect to a URL, Use RedirectView.

from django.views.generic import RedirectView  urlpatterns = patterns('',     (r'^one/$', RedirectView.as_view(url='/another/')), ) 
like image 161
Ahsan Avatar answered Sep 20 '22 08:09

Ahsan