3

I'm trying to run a Django project (Mayan EDMS) in Apache. From a Ubuntu 12.10, Apache 2.2.22, Python 2.7.3 and Django (1, 4, 3, 'final', 0).

When I go to the served web it fails and shows me errors in the apache log, they are all errors concerning modules in Python that are not installed, I install the modules and errors changed from one module to other:

sudo easy_install django-pagination
sudo easy_install South
sudo easy_install requests
sudo easy_install mptt

It all seems to go fine till a module named djangorestframework is needed. I install it successfully:

pip install djangorestframework

but it's still not found:

[Mon Dec 24 20:15:29 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 86, in load_app
[Mon Dec 24 20:15:29 2012] [error] [client 127.0.0.1]     app_module = import_module(app_name)
[Mon Dec 24 20:15:29 2012] [error] [client 127.0.0.1]   File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
[Mon Dec 24 20:15:29 2012] [error] [client 127.0.0.1]     __import__(name)
[Mon Dec 24 20:15:29 2012] [error] [client 127.0.0.1] ImportError: No module named djangorestframework

When I run manually python in shell and I make an import of the previous installed modules (requests, mptt) everything is ok, but I cannot import a djangorestframework module.

>>> import djangorestframework
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named djangorestframework
>>> 

After reading the how to install djangorestframework I see that when it's declared in INSTALLED_APPS it's declared as rest_framework, I try to import rest_framework in python and it accepts it successfully. I guessed that I only had to rename the reference to the module in the Django source. The problem is that I found lots of mentions of it in the files and I intuit it's not a good idea.

what can I be doing wrong? The installation is so simple, I encourage readers just to install the module

pip install djangorestframework

and try to import it in Python

import djangorestframework 

I've tried it in two computers and same problem occurred (both computers have the same Ubuntu/Apache/Django configuration).

4

1 回答 1

5

它安装在 site-packages/rest_framework 中,所以你应该使用:

import rest_framework
于 2012-12-25T08:21:12.793 回答