Django Rest Framework — no module named rest_frame

2020-05-19 03:28发布

问题:

I've installed django rest framework using pip install djangorestframework yet I still get this error when I run "python3 manage.py sycndb":

ImportError: No module named 'rest_framework'

I'm using python3, is this my issue?

回答1:

You need to install django rest framework using pip3 (pip for python 3):

pip3 install djangorestframework

Instructions on how to install pip3 can be found here



回答2:

if you forget ,,this will happen,it's weird

wrong example: need a ,

INSTALLED_APPS = [
'rest_framework'
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]


回答3:

Also, check for the possibility of a tiny typo:

It's rest_framework with an underscore (_) in between!

Took me a while to figure out that I was using a dash instead...