Upgrade from Django 1.3 to Django 1.4

    Published on August 12, 2014

    Recently I had the pleasure to update from Django 1.3 to Django 1.4. Due to security reasons, it is recommended to update to newer Django releases, furthermore, a Django Version older than 1.3 is not supported anymore.

    For those upgrading to a new version of Django, you will need to check all the backwards-incompatible changes and deprecated features for each ‘final’ release from the one after your current Django version, up to and including the new version.

    I recommend to upgrade from one release step to another step and not to jump from version 1.3 to e.g. 1.6. I will write my experiences during a Django update from 1.4 to 1.5 in a separate blog entry.

    Now in this blog entry I will show those backwards-incompatibilities I had to face during my update process from Django 1.3 to 1.4. I hope you will find some hints that will help you to successfully update your project as well:

    Updated default project layout and

    If you try to start your localhost server by doing python runserver after you have downloaded and installed Django 1.4, you will get the follwing error:

    Error: Can't find the file '' in the directory containing ''. It appears you've customized things. You'll have to run, passing it your settings module. (If the file does indeed exist, it's causing an ImportError somehow.)

    This is because Djangos project structure has changed. Until Django 1.3 the file was located within the project folder like this:


     Place outside the mysite/ directory and edit it like this:

    #!/usr/bin/env python
    import os, sys
    if __name__ == "__main__":
        os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
        from import execute_from_command_line

    {{ project_name }} should be replaced with the Python package name of the actual project.

    If you leave myapp/ folder as described above, you should import mysite.settings, mysite.urls, and mysite.myapp, but not settings, urls, or myapp as top-level modules.

    If you want to import your apps as top-level modules you must replace your apps folders adjacent to the new like this:

    Otherwise you will get "ImportError: no module named <myapp> in *.py".

    Module “django.core.context_processors” does not define a “auth” callable request processor

    django.core.context_processors.auth was completely removed in Django 1.4, so you need to make the following change to TEMPLATE_CONTEXT_PROCESSORS in your file:

    # old
    TEMPLATE_CONTEXT_PROCESSORS = ("django.core.context_processors.auth",
    # new
    TEMPLATE_CONTEXT_PROCESSORS = ("django.contrib.auth.context_processors.auth",

    Loading template Error

    The ability to specify a callable template loader rather than a Loader class will be removed, as will the load_template_source functions that are included with the built in template loaders for backwards compatibility. So after an upgrade from Django 1.3 to Django 1.4 you will get the following error:

    django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'"

    So you need to make the following change to TEMPLATE_LOADERS in your file:


    Some third party apps incompatibilities with Django 1.4


    The recent of ckeditor-updated version 4.4.0 throws the following error after the Django 1.4 upgrade:

    ImportError: cannot import name force_text

    So you need to upgrade to the latest Django 1.4 (as of 07-08-2014 - the "1.4.13").


    If you want to use a Cross Site Request Forgery protection you need to use the csrf_token tag inside the <form> element in any template that uses a POST form, e.g.:

    <form action="." method="post">{% csrf_token %}

    and make the following change to MIDDLEWARE_CLASSES in your file:



    So far, this entry has 0 comments.

    Post a comment

Buchempfehlungen pix pix
May 2019
Über pix

Ich bin Diplom Informatiker und das ist meine persönliche Internet sowie weblog Seite.mehr Informationen...