python - 谷歌分析小部件的问题
问题描述
Google 分析小部件在管理页面中如下所示:
当我按下消息时,出现此错误:
错误在文件“venv/lib/site-packages/django/forms/boundfield.py”中,在以下函数中:
def as_widget(self, widget=None, attrs=None, only_initial=False):
"""
Render the field by rendering the passed widget, adding any HTML
attributes passed as attrs. If a widget isn't specified, use the
field's default widget.
"""
widget = widget or self.field.widget
if self.field.localize:
widget.is_localized = True
attrs = attrs or {}
attrs = self.build_widget_attrs(attrs, widget)
if self.auto_id and 'id' not in widget.attrs:
attrs.setdefault('id', self.html_initial_id if only_initial else self.auto_id)
return widget.render(
name=self.html_initial_name if only_initial else self.html_name,
value=self.value(),
attrs=attrs,
renderer=self.form.renderer,
)
其中小部件可以是 TextInput 或 Textarea :
from django.forms.widgets import Textarea, TextInput
然而,在文件“venv/lib/site-packages/django/forms/widgets.py”中,小部件类包含这个渲染函数,其中包含渲染器作为参数:
def render(self, name, value, attrs=None, renderer=None):
"""Render the widget as an HTML string."""
context = self.get_context(name, value, attrs)
return self._render(self.template_name, context, renderer)
谁能帮我这个?
解决方案
推荐阅读
- c# - xaml 中的命令绑定与 MVVM
- bash - Azure Devops 使用存储库名称获取 repositoryId
- c# - 将返回 T 的特定实现的方法分配给 Func
多变的 - python - matplotlib.pyplot.streamplot()中maxlength、minlength和start_points参数的意义是什么?
- java - Quarkus Maven 插件不再构建
- angular - PrimeNg OverlayPanel 与自定义模板参数
- django - 如何在 Django 中覆盖 Heroku 数据库设置?
- javascript - 是否可以/可以在 NodeJS 中对给定函数进行快照(模拟)以便进行更快的测试或本地开发环境?
- java - org.springframework.orm.jpa.JpaSystemException:无法反序列化
- angular - 无头测试中未提供嵌套的 @Self() ngControl