【问题标题】:404 error constructing link from parameter from "def get(self, notebook_id):"从“def get(self, notebook_id):”的参数构造链接时出现 404 错误
【发布时间】:2012-08-02 19:01:26
【问题描述】:

我收到了带有此网址的可怕的 404 html 错误消息

http://localhost:8088/editnotebook/Roger

链接是用这个 href 生成的。

{% for page in pages %}
<li><a href="/editnotebook/{{ page }}">  {{ page }} </a></li>
{% endfor %}

python代码如下。

def get(self, notebook_id):
    iden = notebook_id
    notebook = db.get(db.Key.from_path('Notebooks', iden))
    self.render_template('editnotebook.html', {'notebook': notebook})

型号如下。

from models import Notes, Notebooks

class Notebooks(db.Model):
    user = db.StringProperty()
    moreinfo = db.StringProperty(multiline=True)
    deleteRequested = db.BooleanProperty(default=False)

这些信息足以说明我收到 404 错误的原因并可能修复它吗?

这个问题与the question here有关。

【问题讨论】:

  • app.yamlroutes.py 在这里可能更相关。
  • 是的,routes.py 正是问题所在。我没有添加到链接([\w]+)。非常感谢。 ('/editnotebook/([\w]+)', EditNotebook),

标签: html google-app-engine python-2.7


【解决方案1】:

hyperslug 注意到我没有发布我的 routes.py 代码确实回答了这个问题。 在 routes.py 中,您必须添加正则表达式 ([\w]+) 以容纳链接参数。

【讨论】:

    猜你喜欢
    • 2021-09-26
    • 1970-01-01
    • 2013-11-15
    • 2014-05-26
    • 2016-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多