【发布时间】:2021-04-14 02:46:36
【问题描述】:
这是我的 base_site.html 代码
{% extends "admin/base.html" %}
{% load static %}
{% block title %}{% if subtitle %}{{ subtitle }} | {% endif %}{{ title }} |
{{ site_title|default:_('Admin') }}
{% endblock %}
{% block extrastyle %}
<style type="text/css">
#branding h1{
color: #fff !important;
}
#branding h1 a:link, #branding h1 a:visited {
color: #fff !important;
}
.submit-row input{
background-color: #00b388;
}
#header {
background-color: #000000;
color: #fff !important;
}
.module caption{
background-color: #00b388;
}
div.breadcrumbs {
background: #00b388;
}
.object-tools a.addlink{
background-color: #00b388;
}
input[type=submit].default, .submit-row input.default{
background-color: #00b388;
}
</style>
{% endblock %}
{% block branding %}
<form method="post">{% csrf_token %}
<h1 id="site-name"><a href="{% url 'admin:index' %}"><img src="{% static 'img/logo.PNG' %}" height="30px" /></a></h1>
{% endblock %}
{% block nav-global %}
{% endblock %}
unfortunately i have added the <form> tag in the above code, just to over come with CSRF issue and it does.
unfortunately, this approach gives me another error,
也就是说,我的模型中有 3 个文件字段,尽管我在上传过程中提到了这些文件,当我点击提交时,它不起作用并一直显示此字段是必填错误。
I am new to Django and your response helps me great.
versions:-
Django - 2.2
python - 3.6.2
【问题讨论】:
-
你能显示你的错误的完整回溯吗?
-
您的表单标签未关闭。正常吗?
-
@EricMartin 如果我关闭表单标签,不幸的是我看到了 403 禁止错误..
-
你有 403 的堆栈跟踪吗?
-
嗨@EricMartin 关闭
标签: html css django overriding csrf