cs50 python&js web:尝试“makemigrations”后无法操作网站

kmbjn2e3  于 2021-09-08  发布在  Java
关注(0)|答案(0)|浏览(181)

我一直在网上学习python和django的cs50课程。
当我进入“makemigrations”阶段时,它没有运行,我也不能使用命令“runserver”。

PS C:\Users\44777\code\airline> python3 manage.py runserver 
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 591, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "D:\Python38\lib\threading.py", line 870, in run
    self._target(*self._args,**self._kwargs)
  File "D:\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args,**kwargs)
  File "D:\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "D:\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
    all_issues = checks.run_checks(
  File "D:\Python38\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "D:\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "D:\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 409, in check
    messages.extend(check_resolver(pattern))
  File "D:\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 408, in check
    for pattern in self.url_patterns:
  File "D:\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'flights.urls' from 'C:\\Users\\44777\\code\\airline\\flights\\urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
PS C:\Users\44777\code\airline> python3 manage.py makemigrations
Traceback (most recent call last):
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 591, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "D:\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "D:\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args,**cmd_options)
  File "D:\Python38\lib\site-packages\django\core\management\base.py", line 368, in execute
    self.check()
  File "D:\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
    all_issues = checks.run_checks(
  File "D:\Python38\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "D:\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "D:\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 409, in check
    messages.extend(check_resolver(pattern))
  File "D:\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 408, in check
    for pattern in self.url_patterns:
  File "D:\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Python38\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'flights.urls' from 'C:\\Users\\44777\\code\\airline\\flights\\urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

我被告知我可以使用CS50API使事情变得更简单,但我在windows机器上使用vs代码。我还知道讲师使用mac。有人知道如何解决我的问题吗?谢谢
-马克斯
编辑:在从头开始再次阅读教程之后,我遇到了同样的问题。查看语法时出现错误:
modulenotfounderror:没有名为“flights.url”的模块
我去了这个显示的位置,然后意识到我忘记了flights.url中的“s”。这可能不是我过去遇到的问题,但现在我的代码允许我进行迁移。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题