Error when trying to start Django runserver in Windows 10


#1

Here’s what I’m getting when trying to start the Django server. (This worked before I did the edits for setting up templates [chapter 4])

(venv) C:\projects\myhellowebapp>python manage.py runserver
Performing system checks…

Unhandled exception in thread started by <function check_errors..wrapper at 0x04607468>
Traceback (most recent call last):
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\utils\autoreload.py”, line 225, in wrapper
fn(*args, **kwargs)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\core\management\commands\runserver.py”, line 120, in inner_run
self.check(display_num_errors=True)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\core\management\base.py”, line 364, in check
include_deployment_checks=include_deployment_checks,
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\core\management\base.py”, line 351, in run_checks
return checks.run_checks(**kwargs)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\core\checks\registry.py”, line 73, in run_checks
new_errors = check(app_configs=app_configs)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\core\checks\urls.py”, line 13, in check_url_config
return check_resolver(resolver)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\core\checks\urls.py”, line 23, in check_resolver
return check_method()
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\urls\resolvers.py”, line 399, in check
for pattern in self.url_patterns:
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\utils\functional.py”, line 36, in get
res = instance.dict[self.name] = self.func(instance)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\urls\resolvers.py”, line 540, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\utils\functional.py”, line 36, in get
res = instance.dict[self.name] = self.func(instance)
File “C:\projects\myhellowebapp\venv\lib\site-packages\django\urls\resolvers.py”, line 533, in urlconf_module
return import_module(self.urlconf_name)
File "C:\projects\myhellowebapp\venv\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in _find_and_load
File “”, line 967, in _find_and_load_unlocked
File “”, line 677, in _load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in call_with_frames_removed
File “C:\projects\myhellowebapp\hellowebapp\urls.py”, line 16, in
from django.conf.urls import path
ImportError: cannot import name ‘path’ from ‘django.conf.urls’ (C:\projects\myhellowebapp\venv\lib\site-packages\django\conf\urls_init
.py)

I appreciate any help in resolving this.


#2

OK, I found the solution
in
init.py
I changed ‘re_path’ to ‘path’

I also needed to indent line 6 in
views.py