[[TemplateSyntaxError,同时使用typeform sdk将url参数传递给类]
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[[TemplateSyntaxError,同时使用typeform sdk将url参数传递给类]相关的知识,希望对你有一定的参考价值。
我正在使用Django。我使用https://pypi.org/project/django-typeform/
点安装了sdk的typeform我想在[iframe中提及Passing URL parameter in iframe issue中传递Pass URL参数
我尝试使用以下https://glitch.com/edit/#!/tf-embed-with-params?path=README.md:1:0
但是这给了我
Exception Type: TemplateSyntaxError
Exception Value:
'sekizai_tags' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
django_typeform
i18n
l10n
log
static
tz
settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'wfhApp',
'django_typeform.apps.DjangoTypeformConfig',
]
我的html页面如下:
<!DOCTYPE html>
% load django_typeform %
<html>
<head>
<title>Hello!</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<h1>Hi there!</h1>
<div class="target-dom-node" style="width: 100%; height: 500px;"></div>
<script src="https://embed.typeform.com/embed.js"></script>
<script src="/survey/script.js"></script>
% typeforms_embed 'https://theother2thirds.typeform.com/to/hNZW30' 'New typeform' '"hideHeaders": true, "hideFooter": true' %
</body>
</html>
追踪:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/wfhApp/survey/
Django Version: 3.0.3
Python Version: 3.8.1
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'wfhApp',
'django_typeform.apps.DjangoTypeformConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Template error:
In template C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django_typeform\templates\django_typeform\typeform_embed.html, error at line 1
'sekizai_tags' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
django_typeform
i18n
l10n
log
static
tz
1 : % load sekizai_tags static %
2 : <div class=" selector "></div>
3 : % addtoblock 'js' %<script src="https://embed.typeform.com/embed.js"></script>% endaddtoblock %
4 : % addtoblock 'js' %% spaceless %
5 : <script src="% static 'django_typeform/embed.js' %"></script>
6 : <script>
7 : (function ()
8 : var el = document.querySelector('. selector ');
9 : var url = ' url ';
10 : var options = options|safe ;
11 : typeformEmbed.makeWidget(el, url, options);
Traceback (most recent call last):
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\defaulttags.py", line 1021, in find_library
return parser.libraries[name]
During handling of the above exception ('sekizai_tags'), another exception occurred:
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
response = get_response(request)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Admin\Pictures\WFH_project\wfhProject\wfhApp\views.py", line 14, in survey
return render(request,'wfhApp/survey.html')
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\loader.py", line 62, in render_to_string
return template.render(context, request)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\backends\django.py", line 61, in render
return self.template.render(context)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 171, in render
return self._render(context)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 163, in _render
return self.nodelist.render(context)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 936, in render
bit = node.render_annotated(context)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 903, in render_annotated
return self.render(context)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\library.py", line 225, in render
t = context.template.engine.get_template(self.filename)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\engine.py", line 143, in get_template
template, origin = self.find_template(template_name)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\engine.py", line 125, in find_template
template = loader.get_template(name, skip=skip)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\loaders\base.py", line 29, in get_template
return Template(
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 156, in __init__
self.nodelist = self.compile_nodelist()
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 194, in compile_nodelist
return parser.parse()
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 477, in parse
raise self.error(token, e)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\base.py", line 475, in parse
compiled_result = compile_func(self, token)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\defaulttags.py", line 1078, in load
lib = find_library(parser, name)
File "C:\Users\Admin\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\template\defaulttags.py", line 1023, in find_library
raise TemplateSyntaxError(
Exception Type: TemplateSyntaxError at /wfhApp/survey/
Exception Value: 'sekizai_tags' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
django_typeform
i18n
l10n
log
static
tz
答案
似乎该软件包使用了sekizai_tags
,但不再将sekizai列为必要条件旧安装docs
django_typeform要求安装django-sekizai(应该发生自动按照以上说明进行操作)。 Sekizai用于定位HTML正文的ebnd中的javascript元素。
您可能应该添加django_sekizai
以上是关于[[TemplateSyntaxError,同时使用typeform sdk将url参数传递给类]的主要内容,如果未能解决你的问题,请参考以下文章
Django:TemplateSyntaxError:无法解析剩余部分
jinja2.exceptions.TemplateSyntaxError: 意外字符 '\\'
jinja2.exceptions.TemplateSyntaxError: 意外的 '%'
Django:TemplateSyntaxError:无法解析剩余部分:'|'来自“资格日期|”