ImportError: cannot import name 'Origin' with Django 1.10

Bug #1661662 reported by Brendan Donegan
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Invalid
High
Unassigned

Bug Description

With Django 1.10 installed we get the following traceback in regiond.log when we attempt to login:

 Traceback (most recent call last):
   File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 118, in callWithContext
     return self.currentContext().callWithContext(ctx, func, *args, **kw)
   File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 83, in callWithContext
     self.contexts.pop()
   File "/usr/lib/python3/dist-packages/provisioningserver/utils/twisted.py", line 857, in callInContext
     return func(*args, **kwargs)
   File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 522, in run
     self.started = True
 --- <exception caught here> ---
   File "/usr/lib/python3/dist-packages/twisted/web/wsgi.py", line 497, in run
     appIterator = self.application(self.environ, self.startResponse)
   File "/usr/lib/python3/dist-packages/django/core/handlers/wsgi.py", line 189, in __call__

   File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 224, in get_response
     response = get_response(request)
   File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 213, in get_response
     request, get_resolver(None), sys.exc_info())
   File "/usr/lib/python3/dist-packages/maasserver/utils/views.py", line 144, in handle_uncaught_exception
     response = upcall(request, resolver, exc_info)
   File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 268, in handle_uncaught_exception

   File "/usr/lib/python3/dist-packages/django/utils/decorators.py", line 110, in _wrapped_view

   File "/usr/lib/python3/dist-packages/django/views/defaults.py", line 68, in server_error
     template = loader.get_template(template_name)
   File "/usr/lib/python3/dist-packages/django/template/loader.py", line 35, in get_template
     """
   File "/usr/lib/python3/dist-packages/django/template/backends/django.py", line 30, in get_template
     options['libraries'] = self.get_templatetag_libraries(libraries)
   File "/usr/lib/python3/dist-packages/django/template/engine.py", line 167, in get_template
     """
   File "/usr/lib/python3/dist-packages/django/template/engine.py", line 139, in find_template
     else:
   File "/usr/lib/python3/dist-packages/django/utils/functional.py", line 59, in __get__
     Encapsulate a function call and act as a proxy for methods that are
   File "/usr/lib/python3/dist-packages/django/template/engine.py", line 94, in template_loaders
     return [import_library(x) for x in builtins]
   File "/usr/lib/python3/dist-packages/django/template/engine.py", line 99, in get_template_loaders
     loaded[name] = import_library(path)
   File "/usr/lib/python3/dist-packages/django/template/engine.py", line 112, in find_template_loader
     return loaders
   File "/usr/lib/python3/dist-packages/django/utils/module_loading.py", line 26, in import_string
     module_path, class_name)
   File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 986, in _gcd_import

   File "<frozen importlib._bootstrap>", line 969, in _find_and_load

   File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked

   File "<frozen importlib._bootstrap>", line 673, in _load_unlocked

   File "<frozen importlib._bootstrap_external>", line 673, in exec_module

   File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed

   File "/usr/lib/python3/dist-packages/django/template/loaders/filesystem.py", line 10, in <module>
     from django.template import Origin, TemplateDoesNotExist
 builtins.ImportError: cannot import name 'Origin'

MAAS version: 2.2.0~beta1+bzr5675-0ubuntu1
Ubuntu version: zesty

Tags: django1.10
description: updated
Revision history for this message
Nish Aravamudan (nacc) wrote :

Just as a quick check, I ran in a container:

>>> from django.template import Origin
>>>

so I'm not entirely sure why it fails -- is this something that would be easy for me to reproduce, or do you possibly have an idea why it's happening? I don't know that much about Django, but I can try and help out so we can get the merge through.

-Nish

Revision history for this message
Nish Aravamudan (nacc) wrote :

https://docs.djangoproject.com/en/1.10/ref/templates/upgrading/ is I think the underlying issue, but I'm not 100% yet.

Revision history for this message
Nish Aravamudan (nacc) wrote :
Revision history for this message
Blake Rouse (blake-rouse) wrote :

That change looks correct, but we need to make sure that it also works on Django 1.8 as well. If not we will need to be conditional based on versions in that file.

Changed in maas:
milestone: none → next
importance: Undecided → High
status: New → Triaged
Revision history for this message
Nish Aravamudan (nacc) wrote :

Hi Blake,

Understood -- I wasn't sure how BC MAAS trunk needed to be. Is it like curtin that gets SRU'd all over? Or would trunk only be on the latest Ubuntu? If the former, then yes, we'd need conditionality, but if the latter, I would hold off on the change until a cycle where we plan to merge Django (z+1 currently).

Revision history for this message
Andres Rodriguez (andreserl) wrote :

Hi!

**This is an automated message**

We believe this is may no longer be an issue in the latest MAAS release. Due to the original date of the bug report, we are currently marking it as Invalid. If you believe this bug report still valid against the latest release of MAAS, or if you are still interested in this, please re-open this bug report.

Thanks

Changed in maas:
status: Triaged → Invalid
Changed in maas:
milestone: next → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.