[英]MongoEngine/MongoDB and Django unable to “add more urls” into urls.py
So Everything works fine with my initial 5 urls in the urls.py
file. 因此,一切都可以在urls.py
文件中的最初5个URL正常运行。
urlpatterns = patterns('',
url(r'^add/$', PostCreateView.as_view(), name='create'),
url(r'^$', PostListView.as_view(), name='list'),
url(r'^(?P<pk>[\w\d]+)/$', PostDetailView.as_view(), name='detail'),
url(r'^(?P<pk>[\w\d]+)/edit/$', PostUpdateView.as_view(), name='update'),
url(r'^(?P<pk>[\w\d]+)/delete/$', PostDeleteView.as_view(), name='delete'),
)
But when I add an extra line. 但是当我添加额外的一行时。 Let's say 比方说
url(r'^test/$', test.as_view(), name='test'),
I am hit with a 500 Server error page and with debugging it is stating that there is a validation error?
我遇到500 Server错误页面,并且进行调试时显示存在validation error?
"test is not a valid objectid"
i feel it's an issue with mongoengine but do not what or where. 我觉得这是mongoengine的问题,但不要在哪里或在哪里。
The order of the rules matter. 规则的顺序很重要。 This rule will match test/
: 此规则将匹配test/
:
url(r'^(?P<pk>[\w\d]+)/$', PostDetailView.as_view(), name='detail'),
Define your rules like this: 像这样定义您的规则:
urlpatterns = patterns('',
url(r'^add/$', PostCreateView.as_view(), name='create'),
url(r'^$', PostListView.as_view(), name='list'),
url(r'^test/$', test.as_view(), name='test'),
url(r'^(?P<pk>[\w\d]+)/$', PostDetailView.as_view(), name='detail'),
url(r'^(?P<pk>[\w\d]+)/edit/$', PostUpdateView.as_view(), name='update'),
url(r'^(?P<pk>[\w\d]+)/delete/$', PostDeleteView.as_view(), name='delete'),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.