0

I have been working through the Web with Python and Django with the CS50 course.

When i got to the stage of 'makemigrations' it didnt run and not i cant use the command 'runserver' either.

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.

I was told that I could use the CS50 API to make things easier, but I am using VS Code on a Windows machine. I also know that the lecturer uses Mac. Does anyone know how to solve my problem? Thanks

-Max

EDIT:After going through the tutorial again from scratch i got the same problem. While looking through the syntax there was an error:

ModuleNotFoundError: No module named 'flights.url'

I went to the location that this was displayed and then realised i had forgotten a 's' in flights.urls. This was possibly not the problem i had in the past but now my code is allowing me to makemigrations.

0 Answers0