Normaly在url.py文件中寻找一个url。如果找到了,则加载相关的HTML页面,如果找不到,则显示:带有msg的Page not found (404):
看到这个错误是因为Django设置文件中有DEBUG = True。将其更改为False,Django将显示一个标准404页。
我想改变django展示的标准404 page。我有一个创建了PageNotFound.html的HTML页面,我希望django在每次出现Page not found (404)时都显示DEBUG = False。我该怎么做?
我想自定义此错误:
Page not found
No template exists to render the document at url 'someurl'.
This page is intentionally left ugly ;-)
我编辑了umbracosettings.config:
<errors>
<error404>4568</error404>
</errors>
但出于某些原因,自定义404可以与某些页面一起工作,而不能与其他页面一起工作。
我想知道代码的最佳部分来捕获一个与模板不匹配的404。不过,此时我将检查url字符串,并输出自己的动态html (如果它与模式匹配)。它是动态内容,因为它的wordpress后端中没有内容。因此,我希望回显html和退出,如果它匹配。如果没有,那么继续404和正常。
也提到这个问题。动态URL生成动态内容
TY
http://127.0.0.1:8000/app/slug/
有了Debug=True,我就得到了Page not found (404) - No entry found matching the query。使用Debug=False时,我看到的是projectName/templates/500.html而不是404.html。
两者看起来完全一样。500.html
{% extends "base.html" %}
{% block title %}server error{% endblock %}
{% block content %}
<h3>
在App\Exception\Handler中,我想根据获得的HTTP状态代码返回一个自定义视图。
如果statuscode == 404返回404视图等等,但我无法找到正确的语法,我想知道Handler类是否是正确的位置。
public function render($request, Exception $exception)
{
if (App::environment('local')) {
return parent::render($request, $exception);
}
// what do I do here
我正在使用机车CMS,我想翻译一些字符串。我的tanslations.yml文件中有以下数据:
general:
404:
title:
en: "404 Page Not Found"
fr: "404 - Page non trouvée"
de: "404 Seite nicht gefunden"
es: "404 Página no encontrada"
pt-BR: "404 Página não e
我想,如果网址是 (示例),系统将显示404模板。
这是我的代码:
function _display_404_template() {
$current_url = get_current_url(); // get current url
if ( $current_url === 'http://mysite.domain/url-for-404/' ) {
global $wp_query;
$wp_query->set_404();
status_header(404