流浪的小李子吖
2023-09-22 04:22 deepin
求回复啊!!!!!!!!(加急求回复)
Reply Like 0 View the author
求回复啊!!!!!!!!(加急求回复)
求回复啊!!!!!!!!(加急求回复)
建议看django官网教程,很详细了,有include的详细用法,这是没导入进来的报错。
太深奥了
非常感谢2楼,现在变成了404错误
无语了
稍后见5楼
给错误信息
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/ |
Using the URLconf defined in lmosdold.urls
, Django tried these URL patterns, in this order:
The empty path didn’t match any of these.
服了django4.2.0
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/ |
Using the URLconf defined in lmosdold.urls
, Django tried these URL patterns, in this order:
The empty path didn’t match any of these.
服了django4.2.0
@floatingdream帮忙啊!!!
Popular Events
More
这不,我在做灵墨的下载网页嘛,偏偏好事多磨,非得出错并无法执行migrate(相当于无法创建数据库)
但是我没法,只好找你们求救了
刚从百度AI找来了下载网页的代码,结果运行一看,完了,坏了,没办法,问一下有没有解决方法
百度AI给的:
下面是一个使用 Django 框架来编写一个网页,当用户点击链接时,就会向用户发送文件的示例代码。注意,以下代码不包括文件上传或文件存储的部分,只是文件下载的功能。
首先,我们需要创建一个 Django 项目。可以使用以下命令创建:
然后,在
myproject
文件夹中创建一个新的 Django 应用,例如file_download
:在
file_download
应用中,我们需要创建一个视图函数,该函数会处理文件下载请求。以下是一个简单的示例视图函数:接下来,我们需要在 Django 的 URL 配置文件中配置这个视图函数:
然后,在
file_download
应用中创建一个 URL 配置文件:最后,创建一个 HTML 模板用于展示下载链接:
现在,当你访问
Download File
链接时,就会触发download_file
视图函数,下载指定的文件。请确保替换代码中的文件路径为你实际的文件路径。运行后:
下面是一个使用 Django 框架来编写一个网页,当用户点击链接时,就会向用户发送文件的示例代码。注意,以下代码不包括文件上传或文件存储的部分,只是文件下载的功能。
首先,我们需要创建一个 Django 项目。可以使用以下命令创建:
然后,在
myproject
文件夹中创建一个新的 Django 应用,例如file_download
:在
file_download
应用中,我们需要创建一个视图函数,该函数会处理文件下载请求。以下是一个简单的示例视图函数:接下来,我们需要在 Django 的 URL 配置文件中配置这个视图函数:
然后,在
file_download
应用中创建一个 URL 配置文件:最后,创建一个 HTML 模板用于展示下载链接:
现在,当你访问
Download File
链接时,就会触发download_file
视图函数,下载指定的文件。请确保替换代码中的文件路径为你实际的文件路径。运行后:
(lmos) lldxlz@lldxlz-x201e:~/lingmo_os/lmosdold$ python manage.py migrate
Traceback (most recent call last):
File "/home/lldxlz/lingmo_os/lmosdold/manage.py", line 22, in
main()
File "/home/lldxlz/lingmo_os/lmosdold/manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/management/init.py", line 442, in execute_from_command_line
utility.execute()
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/management/init.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 100, in handle
self.check(databases=[database])
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/management/base.py", line 485, in check
all_issues = checks.run_checks(
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/core/checks/urls.py", line 24, in check_resolver
return check_method()
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/urls/resolvers.py", line 494, in check
for pattern in self.url_patterns:
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/urls/resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/lldxlz/lingmo_os/lmos/lib/python3.9/site-packages/django/urls/resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.9/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 "/home/lldxlz/lingmo_os/lmosdold/lmosdold/urls.py", line 23, in
path('file_download/',include('file_download.urls')),
NameError: name 'include' is not defined
这个nameerror我还看得清楚
是找不到include
但是离谱的就来了
这是urls的解释说明
"""
URL configuration for lmosdold project.
The `urlpatterns` list routes URLs to views. For more information please see:
Examples:
Function views
Class-based views
Including another URLconf
"""
请问这个
真的服了