No module named simple (Django)

Upgrading an application from lower Django version to upper can be a problem when it carries with
a lot many errors with it. This usually occurs when we migrate from Django 1.4.* to Django 1.5.*. This is usually because Django 1.5 and plus totally supports class based views, so with this come some changes in some modules. Most common error during this situation is :
error2
This error is because the old Django version used “direct_to_template” in the urls.py file but bow it is changed to Template view. The change in code can be easily figured out here :
[old]urls.py


from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
                (r'^admin/', include(admin.site.urls)),
                (r'^$', direct_to_template,
                    { 'template': 'index.html' }, 'index')
)

[New]urls.py


from django.conf.urls.defaults import *
from django.views.generic import TemplateView
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
                (r'^admin/', include(admin.site.urls)),
                (r'^accounts/', include('userprofile.urls')),
        (r'^$', TemplateView.as_view(template_name="index.html")),
)

This code will surely get you out of trouble.

This is not the end. There is also a problem with getting the urls. In the templates where we have the urls called like :

{% url login %}

These gives the error as shown below :

errorThis error can be easily removed by simply replacing the above code with :

To remove this you’ll need to go through all of your template files and replace this:

{% url something.else foo bar %}

with this

{% url "something.else" foo bar %}

With this all of your errors will be removed. Let me know if you are facing more errors.
Happy Coding..!!

Advertisements

One thought on “No module named simple (Django)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s