2017-02-02 4 views
0

Ich versuche djangotoolbox.fields von Listfield zu verwenden, aber es ist mir ein Fehler geben zu sagen:kann nicht importiert importlib

Traceback (most recent call last): 
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
fn(*args, **kwargs) 
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run 
autoreload.raise_last_exception() 
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception 
six.reraise(*_exception) 
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper 
fn(*args, **kwargs) 
File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup 
apps.populate(settings.INSTALLED_APPS) 
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 108, in populate 
app_config.import_models(all_models) 
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 202, in import_models 
self.models_module = import_module(models_module_name) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module 
__import__(name) 
File "/Users/coderahul/Desktop/Experiment Box/Innovation/Codeplay/codeplay/data_aggregator/models.py", line 9, in <module> 
from djangotoolbox.fields import ListField 
File "/Library/Python/2.7/site-packages/djangotoolbox/fields.py", line 4, in <module> 
from django.utils.importlib import import_module 
ImportError: No module named importlib 

Was mache ich falsch?

+0

Mögliche Duplikat [Wie mit importlib.import \ _Module ein Modul in Python importieren] (http://stackoverflow.com/questions/10675054/how-to-Import-ein-Modul-in-Python-mit-Import-Import-Modul) – JavaQueen

+1

Importlib ist kein Django-Util, es ist im Python-Standard. Nur 'aus Importlib importieren Import_Modul'. –

Antwort

0

Verwendung from importlib import import_module

2

django.utils.importlib ist eine Kompatibilitätsbibliothek für Python 2.6, wenn noch unterstützt wurde. Es ist seit Django 1.7 obsolet geworden, welches die Unterstützung für Python 2.6 löschte und in 1.9 pro Entwertung Zyklus entfernt wird.

Versuchen Sie, diese

from importlib import import_module 

Quelle here.

+0

Wo sollte ich das hinzufügen? In Modellen? – coderahul94

+0

@ coderahul94 Welche Django-Version verwendest du? – shuboy2014

+0

Ich bevorzuge die Verwendung von django-1.9 für djangotoolbox, ansonsten verwende NoSQL-Datenbank, wenn du Listfield willst. – shuboy2014

Verwandte Themen