Django:“ editorial”不是注册的名称空间

时间:2019-06-20 19:07:29

标签: python django

我遇到了'editorial' is not a registered namespace

的错误

我的poryect的Github页面:

https://github.com/OmarGonD/el-comercio-editoriales

我发现了类似的问题:

Django - is not a registered namespace

但是我目前正在使用它的解决方案(在项目url文件中使用名称空间),并且仍然出现错误。

保护urls.py:

"""el_comercio_app URL Configuration"""

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
     path("", include("editorial.urls", namespace='editorial')),
]

编辑urls.py:

from django.urls import path
from editorial import views
from django.contrib import admin

app_name = 'editorial'

urlpatterns = [
    path('admin', admin.site.urls),
    path("", views.today_editorial, name="today_editorial")
]

运行测试时发生错误:

  

coverage run manage.py测试社论-v 2

# models test
class EditorialTest(TestCase):

    def create_editorial(self, title="only a test", body="yes, this is only a test"):
        return Editorial.objects.create(title=title, body=body,
               url="https://www.google.com", image = "https://img.elcomercio.pe/files/article_content_ec_fotos/uploads/2019/06/19/5d0ae893b3287.jpeg",
               date=timezone.now())

    def test_today_editorial_view(self):
        url = reverse("editorial:today_editorial")
        resp = self.client.get(url)

        self.assertEqual(resp.status_code, 200)   

0 个答案:

没有答案