【发布时间】:2018-02-18 07:27:52
【问题描述】:
我正在尝试将 mongodb 与 django 一起使用。我的主要项目名称是“mysite”,其中有一个名为“blog”的应用程序,在 blog/models.py 中,我编写了以下部分。
from django.db import models
from djangotoolbox.fields import ListField
class Post(models.Model):
title = models.CharField()
text = models.TextField()
tags = ListField()
comments = ListField()
我已经安装了 djangotoolbox。当我在 python shell 上运行命令时
from blog.models import Post
它显示以下错误。
>>> from blog.models import Post
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "E:\Study\mysite\blog\models.py", line 2, in <module>
from djangotoolbox.fields import ListField
File "C:\Program Files (x86)\Python36-32\Lib\site-packages\djangotoolbox\fields.py", line 4, in <module>
from django.utils.importlib import import_module
ModuleNotFoundError: No module named 'django.utils.importlib'
>>>
为什么会出现这个错误?它的解决方案是什么?因为我在网上找遍了都找不到。
【问题讨论】:
标签: python django mongodb python-3.x listfield