Tsangares Tsangares - 4 months ago 15
Python Question

cannot import name same_origin from authentication.py tastypie django

I was wondering if someone could help me figure out why I am getting a "ImportError: cannot import name same_origin"

Here is the full stack trace:

Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 353, in execute_from
_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 398, in execute
self.check()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,

File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py", line 23, in check_resolver
for pattern in resolver.url_patterns:
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/var/www/will/agora/agora/urls.py", line 6, in <module>
from bin.resources import QuestionResourse, UserResource, ResponseResourse
File "/var/www/will/agora/bin/resources.py", line 1, in <module>
from tastypie.resources import ModelResource
File "/usr/local/lib/python2.7/dist-packages/django_tastypie-0.12.2-py2.7.egg/tastypie/resources.py", line
20, in <module>
from tastypie.authentication import Authentication
File "/usr/local/lib/python2.7/dist-packages/django_tastypie-0.12.2-py2.7.egg/tastypie/authentication.py",
line 11, in <module>
from django.utils.http import same_origin
ImportError: cannot import name same_origin


My installed apps:

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'bin',
'tastypie',
}


What other information would be helpful?

Answer

The same_origin method was removed from django as of version 1.9. You can look at the commit here.

It looks like this was fixed in tastypie as of v0.13.0.

Also, tastypie v0.12 doesn't support django 1.9, but v0.13 does. Upgrade tastypie by running:

$ pip install django-tastypie==0.13.3 

And if you have a requirements.txt file, be sure to update the version number there as well.

Comments