简体   繁体   中英

manage.py runserver importerror

after running python manage.py runserver 0.0.0.0:8000

I get this error message

Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x7fefc10b9190>>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 92, in inner_run
    self.validate(display_num_errors=True)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 280, in validate
    num_errors = get_validation_errors(s, app)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 166, in get_app_errors
    self._populate()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 75, in _populate
    self.load_app(app_name)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/loading.py", line 96, in load_app
    models = import_module('.models', app_name)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/cms/models/__init__.py", line 3, in <module>
    from .pagemodel import *  # nopyflakes
  File "/usr/local/lib/python2.7/dist-packages/cms/models/pagemodel.py", line 6, in <module>
    from django.contrib.auth import get_permission_codename
ImportError: cannot import name get_permission_codename

I've checked out /django/contrib/auth/management/ init .py and the get_permission_codename function exists so I can't see why it's not getting imported.

First, make sure you have Django 1.6 or later installed, because that's when get_permission_codename was added.

The problem might be with old pyc files. You could get rid of these by uninstalling Django completely then reinstalling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM