Google App Engine을 사용하여 데이터를 단일 항목에서 단일 페이지로 검색 할 때 다음 오류가 발생했습니다. foobar.com/page/1가 ID 1에서 모든 데이터를 표시합니다 : 여기 ValueError : 밑이 10 인 int()에 대한 리터럴이 잘못되었습니다.
ValueError: invalid literal for int() with base 10
이 파일은 다음과 같습니다
Views.py
class One(webapp.RequestHandler):
def get(self, id):
id = models.Page.get_by_id(int(str(self.request.get("id"))))
page_query = models.Page.get(db.Key.from_path('Page', id))
pages = page_query
template_values = {
'pages': pages,
}
path = os.path.join(os.path.dirname(__file__), 'template/list.html')
self.response.out.write(template.render(path, template_values))
Urls.py :
(r'/browse/(\d+)/', One),
오류 : 이미 get
핸들러에 전달되는
Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 501, in __call__ handler.get(*groups) File "/Volumes/foobar/views.py", line 72, in get id = models.Page.get_by_id(int(str(self.request.get("id")))) ValueError: invalid literal for int() with base 10: ''
페이지에 단일 항목을 다시 가져 오려고합니다. 예. 로컬 호스트 : 8080/검색/1/- 표시 할 항목 1 로컬 호스트 : 8080/검색/2/- 항목 2 등 등 list.html에 포함 된 표시 할 것 : {페이지 %에서 페이지 %} 을 {{page.title}} {% endfor %} – gpjones