Django - 不能 运行 服务器作为 sudo

Django - can't run server as sudo

我正在创建一个软 AP,以便从中配置我的树莓派无线网络。

我已经有了创建热点的脚本,一个 dhcp 服务器,现在我需要 运行 使用 sudo 的 django 应用程序。

(是的,使用 sudo。我正在从我的 python 脚本中唤醒我的 django 服务器,脚本需要 运行 作为 sudo)

我收到以下错误:

Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/django/urls/conf.py", line 17, in                                                                                                              include
    urlconf_module, app_name = arg
ValueError: too many values to unpack (expected 2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/dist-packages/django/utils/autoreload.py", line                                                                                                              53, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/commands/r                                                                                                             unserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py",                                                                                                              line 395, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.7/dist-packages/django/core/management/base.py",                                                                                                              line 382, in _run_checks
    return checks.run_checks(**kwargs)
  File "/usr/local/lib/python3.7/dist-packages/django/core/checks/registry.py",                                                                                                              line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.7/dist-packages/django/core/checks/urls.py", line                                                                                                              13, in check_url_config
    return check_resolver(resolver)
  File "/usr/local/lib/python3.7/dist-packages/django/core/checks/urls.py", line                                                                                                              23, in check_resolver
    return check_method()
  File "/usr/local/lib/python3.7/dist-packages/django/urls/resolvers.py", line 4                                                                                                             07, in check
    for pattern in self.url_patterns:
  File "/usr/local/lib/python3.7/dist-packages/django/utils/functional.py", line                                                                                                              48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.7/dist-packages/django/urls/resolvers.py", line 5                                                                                                             88, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.7/dist-packages/django/utils/functional.py", line                                                                                                              48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.7/dist-packages/django/urls/resolvers.py", line 5                                                                                                             81, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/pi/Documents/berryAP/networkRegistration/networkRegistration/urls.                                                                                                             py", line 19, in <module>
    url(r'^admin/', include(admin.site.urls)),
  File "/usr/local/lib/python3.7/dist-packages/django/urls/conf.py", line 27, in                                                                                                              include
    'provide the namespace argument to include() instead.' % len(arg)
django.core.exceptions.ImproperlyConfigured: Passing a 3-tuple to include() is n                                                                                                             ot supported. Pass a 2-tuple containing the list of patterns and app_name, and p                                                                                                             rovide the namespace argument to include() instead.

当我 运行 服务器没有 sudo 时,它也能正常工作。

如何将它修复为 运行 服务器作为 sudo?

检查 sudo 和“普通”用户是否具有相同的 python 和 Django 版本。