python编程 从入门到实践 中的项目Django入门
urls.py
from django.conf.urls import url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'','learning_logs.urls', namespace='learning_logs'),
]
views.py
from django.shortcuts import render
# Create your views here.
def index(request):
"""学习笔记主页"""
return render(request,'learning_logs/index.html')
urls.py
"""定义learning_logs的URL模式"""
from django.conf.urls import url
from . import views
urlpattterns = [
#主页
url(r'^$',views.index, name='index')
]
Exception ignored in thread started by: <function check_errors..wrapper at 0x00000223DC105820>
Traceback (most recent call last):
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\core\management\base.py", line 356, in check
all_issues = self._run_checks(
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\core\management\base.py", line 346, in run_checks
return checks.run_checks(**kwargs)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
return check_method()
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\urls\resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\utils\functional.py", line 35, in get
res = instance.dict[self.name] = self.func(instance)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\urls\resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\utils\functional.py", line 35, in get
res = instance.dict[self.name] = self.func(instance)
File "E:\桌面\learning_log\ll_env\lib\site-packages\django\urls\resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python39\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 986, in _find_and_load_unlocked
File "", line 680, in _load_unlocked
File "", line 790, in exec_module
File "", line 228, in _call_with_frames_removed
File "E:\桌面\learning_log\learning_log\urls.py", line 21, in
url(r'','learning_logs.urls', namespace='learning_logs'),
TypeError: url() got an unexpected keyword argument 'namespace'
你的写法好像错了
https://www.cnpython.com/qa/85252
url(r'^comments/', include('comments.urls', namespace='comments')),