Python/Django Fortune Teller App

I have been stuck on this for 2 weeks following videos and trying to start fresh but I keep failing.

This is my error:
Exception in thread django-main-thread:
Traceback (most recent call last):
File “/usr/lib/python3.6/threading.py”, line 916, in _bootstrap_inner
self.run()
File “/usr/lib/python3.6/threading.py”, line 864, in run
self._target(*self._args, **self._kwargs)
File “/usr/local/lib/python3.6/dist-packages/django/utils/autoreload.py”, line 53, in wrapper
fn(*args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/django/core/management/commands/runserver.py”, line 118, in inner_run
self.check(display_num_errors=True)
File “/usr/local/lib/python3.6/dist-packages/django/core/management/base.py”, line 396, in check
databases=databases,
File “/usr/local/lib/python3.6/dist-packages/django/core/checks/registry.py”, line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File “/usr/local/lib/python3.6/dist-packages/django/core/checks/urls.py”, line 13, in check_url_config
return check_resolver(resolver)
File “/usr/local/lib/python3.6/dist-packages/django/core/checks/urls.py”, line 23, in check_resolver
return check_method()
File “/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py”, line 408, in check
for pattern in self.url_patterns:
File “/usr/local/lib/python3.6/dist-packages/django/utils/functional.py”, line 48, in get
res = instance.dict[self.name] = self.func(instance)
File “/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py”, line 589, in url_patterns
patterns = getattr(self.urlconf_module, “urlpatterns”, self.urlconf_module)
File “/usr/local/lib/python3.6/dist-packages/django/utils/functional.py”, line 48, in get
res = instance.dict[self.name] = self.func(instance)
File “/usr/local/lib/python3.6/dist-packages/django/urls/resolvers.py”, line 582, in urlconf_module
return import_module(self.urlconf_name)
File “/usr/lib/python3.6/importlib/init.py”, line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 994, in _gcd_import
File “”, line 971, in _find_and_load
File “”, line 955, in _find_and_load_unlocked
File “”, line 665, in _load_unlocked
File “”, line 674, in exec_module
File “”, line 781, in get_code
File “”, line 741, in source_to_code
File “”, line 219, in _call_with_frames_removed
File “/home/ccuser/workspace/django-fortune-teller/fortuneteller/fortuneteller/urls.py”, line 1
python3 manage.py runserver 0.0.0.0:4001"""fortuneteller URL Configuration
^
SyntaxError: invalid syntax

thank you

The error says invalid syntax, which means you typed in something in a way the python interpreter was not expecting. It pointed to the line where it says python3 manage.py runserver 0.0.0.0:4001"""

which looks like an unclosed comment (but since we don’t know what’s in the file just from reading the error, this could be just the surface of the error/errors.

1 Like

This could’ve happened for a host of reasons, if it had important data I suggest looking up how to recover a corrupted db in whatever RDBMS you’re using (like sqlite).

I suspect it could’ve happened with how you used migrations. But very to say just from a single error with no context.

Nuclear option is to delete the db, recreate it, and run your app.