Django:更改项目名称静态错误

时间:2018-07-20 04:05:34

标签: django static

我刚刚将项目名称从ecommerce更改为my_project。我浏览了每个文件(使用查找功能),并将电子商务更改为my_project。现在,当我尝试运行它时,从命令行出现以下错误:

    Traceback (most recent call last):
  File "C:\\Dev\my_project\lib\site-packages\django\core\handlers\exception.py", line 41, in inner
    response = get_response(request)
  File "C:\\Dev\my_project\lib\site-packages\django\core\handlers\base.py", line 217, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\\Dev\my_project\lib\site-packages\django\core\handlers\base.py", line 215, in _get_response
    response = response.render()
  File "C:\\Dev\my_project\lib\site-packages\django\template\response.py", line 107, in render
    self.content = self.rendered_content
  File "C:\\Dev\my_project\lib\site-packages\django\template\response.py", line 84, in rendered_content
    content = template.render(context, self._request)
  File "C:\\Dev\my_project\lib\site-packages\django\template\backends\django.py", line 66, in render
    return self.template.render(context)
  File "C:\\Dev\my_project\lib\site-packages\django\template\base.py", line 
  ...
  File "C:\\Dev\my_project\lib\site-packages\django\templatetags\static.py", line 102, in url
    return self.handle_simple(path)
  File "C:\\Dev\my_project\lib\site-packages\django\templatetags\static.py", line 117, in handle_simple
    return staticfiles_storage.url(path)
  File "C:\\Dev\my_project\lib\site-packages\django\utils\functional.py", line 238, in inner
    self._setup()
  File "C:\\Dev\my_project\lib\site-packages\django\contrib\staticfiles\storage.py", line 504, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "C:\\Dev\my_project\lib\site-packages\django\core\files\storage.py", line 467, in get_storage_class
    return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
  File "C:\\Dev\my_project\lib\site-packages\django\utils\module_loading.py", line 20, in import_string
    module = import_module(module_path)
  File "C:\\Dev\my_project\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'ecommerce'

此外,页面上的错误是:<link rel="stylesheet" href="{% static 'css/stripe-custom-style.css' %}">静态有问题吗?我不确定会是什么

1 个答案:

答案 0 :(得分:2)

错误消息表明Django仍在尝试动态导入ecommerce模块:

File "C:\\Dev\my_project\lib\site-packages\django\contrib\staticfiles\storage.py", line 504, in _setup
    self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
  File "C:\\Dev\my_project\lib\site-packages\django\core\files\storage.py", line 467, in get_storage_class
    return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
  File "C:\\Dev\my_project\lib\site-packages\django\utils\module_loading.py", line 20, in import_string
    module = import_module(module_path)

您应该检查STATICFILES_STORAGE和/或DEFAULT_FILE_STORAGE设置是否仍指向旧程序包名称。