【发布时间】:2018-10-08 08:48:28
【问题描述】:
我的 django 主站点网址
from django.contrib import admin
from django.urls import path,include
urlpatterns = [
path('ways/', include('ways.urls')),
path('admin/', admin.site.urls),
应用网址
urlpatterns = [
path('newWay/', views.newWay, name='newWay'),
path('waySolved/', views.update_way, name='update_way'),
]
但是每当我点击http://localhost:8000/ways/waySolved/ 它说未找到:/ways/waySolved/ 但http://localhost:8000/ways/newWay/ 完美运行。 在视图中我有这两种功能。 更新方式
def update_way(request):
way_id= request.GET.get('way_id', None)
token=request.GET.get('token', None)
if way_id is not None and token is not None:
token = token.replace("\"", "")
community_osm_cur.execute("""SELECT latitude ,longitude from (SELECT * from (SELECT
latitude,longitude,id from current_nodes where id in (Select node_id from
current_way_nodes where way_id='%s' ORDER BY sequence_id asc )) AS temp1
Inner join
(Select node_id,sequence_id from current_way_nodes where way_id='%s'
ORDER BY sequence_id asc ) As temp2 on temp1.id=temp2.node_id
order by sequence_id asc) As temp3""", ((int)(way_id), (int)(way_id),))
nodes_list = community_osm_cur.fetchall()
coords = []
if len(nodes_list)>0:
for node in nodes_list:
lat = node[0] / 10000000
lng = node[1] / 10000000
coords.append([lat, lng])
position_hash = hashlib.sha3_256(json.dumps(coords).encode()).hexdigest()
community_osm_cur.execute("select user_id from oauth_tokens where secret = %s", (token,))
id = community_osm_cur.fetchone()[0]
updated_way_cur.execute("""INSERT INTO updated_ways (way_id,node_hash) values
(%s,%s) on conflict(way_id) do update set node_hash=%s""",
(way_id,position_hash,position_hash,))
updated_way_cur.execute("Delete from distribution where user_id=%s and id = %s ",(id,way_id,))
updated_way_con.commit()
return HttpResponse(status=200)
return HttpResponse(status=404)
【问题讨论】:
-
抱歉 newway 有一个斜线。它只是打印Not Found: /ways/waySolved/ "GET /ways/waySolved/?way_id=13232323 HTTP/1.1" 404 0 仅此而已
-
显示您的视图函数
-
@Alasdair 视图已添加
标签: python django url url-pattern