运行manage.py迁移时出错

时间:2018-07-13 19:21:45

标签: python django ubuntu-16.04 suricata

当我尝试在Ubuntu 16.04 LTS上运行Scirius项目时出现了无法修复的错误,并且我是该领域的新手。有人可以帮我吗,我需要运行从https://github.com/StamusNetworks/scirius克隆的这个项目

python manage.py migrate

> Traceback (most recent call last):   File "manage.py", line 10, in
> <module>
>     execute_from_command_line(sys.argv)   File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 353, in execute_from_command_line
>     utility.execute()   File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 345, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)   File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 348, in run_from_argv
>     self.execute(*args, **cmd_options)   File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 398, in execute
>     self.check()   File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
> line 426, in check
>     include_deployment_checks=include_deployment_checks,   File "/usr/local/lib/python2.7/dist-packages/django/core/checks/registry.py",
> line 75, in run_checks
>     new_errors = check(app_configs=app_configs)   File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py",
> line 13, in check_url_config
>     return check_resolver(resolver)   File "/usr/local/lib/python2.7/dist-packages/django/core/checks/urls.py",
> line 23, in check_resolver
>     for pattern in resolver.url_patterns:   File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py",
> line 33, in __get__
>     res = instance.__dict__[self.name] = self.func(instance)   File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py",
> line 417, in url_patterns
>     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)   File
> "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py",
> line 33, in __get__
>     res = instance.__dict__[self.name] = self.func(instance)   File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py",
> line 410, in urlconf_module
>     return import_module(self.urlconf_name)   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
>     __import__(name)   File "/home/nasser/majed/scirius/scirius/urls.py", line 5, in <module>
>     from rest_api import router   File "/home/nasser/majed/scirius/scirius/rest_api.py", line 3, in <module>
>     from rest_framework import serializers, viewsets   File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py",
> line 30, in <module>
>     from rest_framework.compat import postgres_fields, unicode_to_repr   File
> "/usr/local/lib/python2.7/dist-packages/rest_framework/compat.py",
> line 21, in <module>
>     from django.urls import (  # noqa ImportError: No module named urls

1 个答案:

答案 0 :(得分:1)

确保您使用的是 Django 2.X ,因为此版本的Django网址已更改 从此版本开始,您必须像这样导入网址。

from django.urls import path

但是在此之前导入看起来像这样

from django.conf.urls import url

所以您和您的教程使用的版本不同,或者您的import语句错误,您可以根据情况进行更改。