我习惯使用网址在django中传递参数,我有以下网址:
mywebsite/view-negotiation/?negotiation=7
我期待以下规则能够抓住它:
url(r'view-negotiation/(?P<negotiation>\d+)', 'myview.views.myview')
但我发现404页面找不到错误。我在这里做错了什么?
答案 0 :(得分:0)
@karthikr给出url模式可以与你的网址匹配
url(r'^view-negotiation/(?P<negotiation>\d+)/$', 'myview.views.myview')
并尝试此操作以从您的视图中访问参数
def myview(request, negotiation):
#negotiation is the parameter catch form url
#i.e nagotiation is a variable that having 7 or any other intiger passed by url
#other stuff goes here