这与之前的 mt 问题有关。我已经看过一些类似问题的答案,但我不确定它们如何应用在这里。
我正在尝试使用 GET 方法在 Django Webserver 上创建内容。当我输入以下网址时:
http://127.0.0.1:8000/maps/createEvent/?name=explosion&reporter=nathaniel&description=something%20exploded&lat=99&lon=99×tamp=2434253
我收到此错误:
invalid literal for int() with base 10: 'explosion'
Request Method: GET
Request URL: http://127.0.0.1:8000/maps/createEvent/?name=explosion&reporter=nathaniel&description=something%20exploded&lat=99&lon=99×tamp=2434253
Django Version: 1.5.2
Exception Type: ValueError
Exception Value:
invalid literal for int() with base 10: 'explosion'
这是有问题的网址:
url(r'^createEvent/$', views.createEvent, name='createEvent')
和视图:
def createEvent(request):
e = Event(request.GET['name'],request.GET['reporter'],request.GET['description'],
request.GET['lat'],request.GET['lon'],request.GET['timestamp'])
e.save()
return HttpResponseRedirect(reverse('maps:event_detail', args=(e.id,)))