Question:
I’m not sure what is causing this error I’m looking to try and runsever on django from windows PowerShell but im am getting that error and this wall of issues.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Unhandled exception in thread started by Traceback (most recent call last): File "D:\Python\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "D:\Python\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run self.check(display_num_errors=True) File "D:\Python\lib\site-packages\django\core\management\base.py", line 374, in check include_deployment_checks=include_deployment_checks, File "D:\Python\lib\site-packages\django\core\management\base.py", line 361, in _run_checks return checks.run_checks(**kwargs) File "D:\Python\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "D:\Python\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config return check_resolver(resolver) File "D:\Python\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "D:\Python\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python\lib\site-packages\django\urls\resolvers.py", line 313, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "D:\Python\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python\lib\site-packages\django\urls\resolvers.py", line 306, in urlconf_module return import_module(self.urlconf_name) File "D:\Python\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File " File " File " File " File " File " File "D:\Python\courseworkupload\courseworkupload\urls.py", line 26, in url(r'^upload/', include('.upload.urls')), File "D:\Python\lib\site-packages\django\conf\urls\__init__.py", line 50, in include urlconf_module = import_module(urlconf_module) File "D:\Python\lib\importlib\__init__.py", line 121, in import_module raise TypeError(msg.format(name)) TypeError: the 'package' argument is required to perform a relative import for '.upload.urls' |
This was done after i ran python manage.py runserver
Any help on the issue would be great
Edit: Adding tree below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
C:. │ db.sqlite3 │ manage.py │ ├───.idea │ courseworkupload.iml │ misc.xml │ modules.xml │ workspace.xml │ ├───courseworkupload │ │ settings.py │ │ urls.py │ │ wsgi.py │ │ __init__.py │ │ │ └───__pycache__ │ settings.cpython-35.pyc │ urls.cpython-35.pyc │ wsgi.cpython-35.pyc │ __init__.cpython-35.pyc │ └───upload │ admin.py │ apps.py │ forms.py │ models.py │ tests.py │ urls.py │ views.py │ __init__.py │ ├───migrations │ __init__.py │ ├───templates └───__pycache__ admin.cpython-35.pyc forms.cpython-35.pyc models.cpython-35.pyc urls.cpython-35.pyc views.cpython-35.pyc __init__.cpython-35.pyc |
Answer:
The leading dot in include('.upload.urls')
is causing the problem.
Assuming that upload
is in your project directory (the one that contains manage.py
), changing it to upload.urls
should work.
1 2 |
url(r'^upload/', include('upload.urls')), |