0

当我尝试我的项目运行服务器时,这个错误

File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\apple\Desktop\web3start\tests\urls.py", line 8, in <module>
    url(r'^', include('web3auth.urls', namespace='web3auth')),
  File "C:\Users\apple\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\conf.py", line 39, in include
    'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in
the included module, or pass a 2-tuple containing the list of patterns and app_name instead.

出来。

配置文件

 if isinstance(urlconf_module, str):
        urlconf_module = import_module(urlconf_module)
    patterns = getattr(urlconf_module, 'urlpatterns', urlconf_module)
    app_name = getattr(urlconf_module, 'app_name', app_name)
    if namespace and not app_name:
        raise ImproperlyConfigured(
            'Specifying a namespace in include() without providing an app_name '
            'is not supported. Set the app_name attribute in the included '
            'module, or pass a 2-tuple containing the list of patterns and '
            'app_name instead.',

网址.py

# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import

from django.conf.urls import url, include


urlpatterns = [
    url(r'^', include('web3auth.urls', namespace='web3auth')),
]

我应该怎么办??我需要一个特定的代码直接写!

4

1 回答 1

2

正如错误所说,在你的内部web3auth/urls.py你需要设置app_name属性。例如:

# web3auth/urls.py

from django.urls import path
from . import views

app_name = 'web3auth'

urlpatterns = [
    ...
]

您也可以结帐documentation

于 2019-08-01T06:18:34.087 回答