Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImproperlyConfigured: Error importing middleware app.middleware: "cannot import name get_host"

Tags:

django

I've just upgraded to Django 1.5, and when I try and access a page, I get the following error:

ImproperlyConfigured: Error importing middleware app.middleware: "cannot import name get_host"

In the shell, I try a similar thing:

>>> from app import middleware
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File ".../middleware.py", line 2, in <module>
    from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect, get_host
ImportError: cannot import name get_host

It's failing on the import of get_host. It doesn't seem that this is deprecated, what's going on?

like image 636
fredley Avatar asked Mar 27 '13 17:03

fredley


1 Answers

In Django 1.5 django.http.get_host() is replaced with request.get_host(). See the methods on HttpRequest object here.

like image 59
Aamir Rind Avatar answered Oct 11 '22 05:10

Aamir Rind