在很多帮助下,我终于让CKEditor更新了相关的文本区域.请看这里的帖子.
但是,当表单上有超过1个CKEditor时,我很难理解如何让CKEditor更新每个相关的文本区域.
这是我目前拥有的jquery.它只更新表单上的最后一个CKEditor关联文本区域:
for (var i in CKEDITOR.instances) {
CKEDITOR.instances[i].on('change', function() { CKEDITOR.instances[i].updateElement() }); //update the relative hidden textarea.
}
Run Code Online (Sandbox Code Playgroud)
当表单上有5个或10个CKEditor时,如何更新每个关联的CKEditor文本区域?
我有一个数据网页,我使用wkhtmltopdf 0.12.3.2(带有修补的qt)导出为pdf.
当数据显示在屏幕上时,它看起来就像我想要的那样,如下所示:
当数据呈现为pdf时,pdf上会出现"重影"边框,如下所示:
当我打印出数据时,页面上会出现更多"鬼"边框,如下所示:
如何防止这些"幽灵"边界出现?我尝试了很多选择,但解决方案让我望而却步.
我试过outline: #fff solid medium !important;但这没效果.我也尝试过,box-shadow: 0px 0px 1px #fff;但这没有效果.
这个问题似乎只出现在CSS border: double值上.
这是我的HTML代码:
<div class="resumeStyleStandardHeadings8" dir="ltr" style="direction: ltr;">Summary Details</div>
Run Code Online (Sandbox Code Playgroud)
这是我的css代码:
.resumeStyleStandardHeadings8 {
background: #000;
border-left: 10px double #fff;
border-bottom: 10px double #fff;
color: #fff;
display: block;
font-weight: 700;
margin-bottom: 2px;
outline: none;
overflow: hidden;
padding: 2px;
padding-bottom: 5px;
padding-top: 5px;
page-break-inside: avoid;
text-transform: uppercase;
vertical-align: middle;
white-space: nowrap;
width: 100%
}
Run Code Online (Sandbox Code Playgroud) 我的表单上有一个表单重置按钮:
<a href="#" id="reset_button" class="btn" onClick="name_of_form.reset();">Reset</a>
Run Code Online (Sandbox Code Playgroud)
这会重置我的表单上除ckeditor之外的所有控件,我希望能够重置表单上的ckeditors的值.
重置ckeditors的相关文本区域.
那么如何将ckeditor的重置编码到表单重置按钮?
我有一个测试模板,允许用户将上传的文件图像以及图像标题作为字符字段添加到用户帐户中。这工作正常。
我现在尝试允许用户编辑已上传的文件图像和图像标题详细信息。
是否可以隐藏图像链接并在其位置显示图像?
我已经阅读了django 文档,搜索了SO和 Google,断断续续地工作了 2 1/2 天,但我仍然无法解决这个问题。
似乎有很多关于如何上传新文件图像的信息,但没有关于如何编辑已上传的文件图像的信息。
这是我的 models.py 代码:
def _get_document_upload_location(instance, filename):
"""
Using a function instead of a lambda to make migrations happy. DO NOT remove or rename this function in the future, as it will break migrations.
@param instance: model instance that owns the FileField we're generating the upload filename for.
@param filename: Original file name assigned by django.
"""
return 'attachments/%d/%s' % (instance.user.id, uuid.uuid4())
class AttachmentDetails(models.Model, FillableModelWithLanguageVersion):
user = …Run Code Online (Sandbox Code Playgroud) 我是 django 的初学者(django 1.7 python 2.7)。
我正在尝试在我的 django 重置密码表单中添加不验证码recaptcha。
我正在尝试使用这个recaptcha djano 插件。
我已按照说明操作并添加了必要的设置:
Installed django-recaptcha to the Python path.
Added captcha to the INSTALLED_APPS setting.
将以下内容添加到我的 settings.py 文件中:
RECAPTCHA_PUBLIC_KEY = '76wtgdfsjhsydt7r5FFGFhgsdfytd656sad75fgh' # fake - for the purpose of this post.
RECAPTCHA_PRIVATE_KEY = '98dfg6df7g56df6gdfgdfg65JHJH656565GFGFGs' # fake - for the purpose of this post.
NOCAPTCHA = True
Run Code Online (Sandbox Code Playgroud)
然后说明建议将验证码添加到表单中,如下所示:
from django import forms
from captcha.fields import ReCaptchaField
class FormWithCaptcha(forms.Form):
captcha = ReCaptchaField()
Run Code Online (Sandbox Code Playgroud)
如何访问内置的重置密码表单?作为初学者,我怀疑我必须自定义内置的重置密码表单,但我该怎么做?我什至不确定内置的重置密码表单在哪里。如何在重置密码表单中自定义构建或推送到教程的示例会很方便。
我已经搜索过 SO & google,但找不到任何合适的东西。
我的模板上有一个 for 循环。我只想显示博客循环中的前 3 项。
目前只有20篇博客文章,但是如果博客文章有500篇或更多,从性能角度来看,是在views.py代码中还是在模板代码中限制循环更好?
这是views.py 文件中的循环限制:
blog_latest_entries = BlogDetails.objects.filter(blog_date_published__lte=date_now).order_by('-blog_date_published')[:3]
.....
return render(request, 'page.html', {
'blog': blog_details_latest_entries,
Run Code Online (Sandbox Code Playgroud)
这是模板代码中的限制:
{% for blog in blog|slice:"3" %}
Run Code Online (Sandbox Code Playgroud)
哪个选项最有利于性能。我怀疑views.py方法,但我希望我的怀疑得到有真正知识的人的支持。
谢谢。
我正在使用 jQuery 1.11。
我有一个以 html 显示的字符串,我希望将相同的字符串复制并粘贴到文本区域。
对我来说问题是要粘贴的字符串包含换行符<br />。为了在文本区域中正确显示字符串,我必须<br />用新行替换换行符\n。
我正在使用replace,但我编写的用 替换 的每个排列<br />都会失败\n。该字符串沿一行打印。
我已经搜索了谷歌等,但这对我不起作用 - 我在这里缺少一些基本的东西。
如何编写字符串替换函数来替换<br />with \n?
这是我的字符串:
[employer]<br />[mm/yyy] - [mm/yyy] - ([number] years1, [number] months)<br /><br />
Run Code Online (Sandbox Code Playgroud)
这是对我不起作用的替换代码:
var text = $(this).closest('.employment_history_suggestion_add_button').prev().text(); // Get text of the previous span element
text = text.replace(/<br\s*\/?>/mg,"\n"); // replace line break with new line for correct display in textarea.
Run Code Online (Sandbox Code Playgroud)
编辑
这是现在有效的代码。
我正在使用.text()- 应该一直使用 …
我使用 django 允许用户上传图像以及描述图像标题的文本。
用户应该能够使用编辑模板编辑图像标题并更改图像文件。这在某种程度上确实有效。
我可以在编辑模板中显示图像文件和图像标题进行编辑。我遇到的问题是,当我在文件上传输入中不包含图像文件时(用户只想更改图像标题而不是图像文件),我的代码确实更改了图像标题,但图像文件被删除从数据库中删除(物理映像文件不会从文件系统中删除)。
我可以成功更新图像详细信息,但用户必须在文件上传输入字段中包含新的图像文件或相同的图像文件,图像标题和图像详细信息才能成功更新。
看来用户必须在文件上传输入字段中包含图像文件。我试图让我的代码像 django admin 一样工作,用户不必每次更改图像标题时都包含图像文件。
如何允许用户更新图像详细信息,而无需每次用户想要更改图像标题时重新上传图像文件?
这是我的 models.py 代码:
编辑#2 - 添加 FillableModelWithLanguageVersion 和 LanguageVersion
# START: ATTACHMENT DETAILS MODEL.
def _get_document_upload_location(instance, filename):
"""
Using a function instead of a lambda to make migrations happy. DO NOT remove or rename this function in the future, as it will break migrations.
@param instance: model instance that owns the FileField we're generating the upload filename for.
@param filename: Original file name assigned by django.
""" …Run Code Online (Sandbox Code Playgroud) django ×4
python ×4
jquery ×3
ckeditor ×2
file-upload ×2
html ×2
image ×2
css ×1
django-forms ×1
django-views ×1
forms ×1
javascript ×1
pdf ×1
recaptcha ×1
replace ×1
wkhtmltopdf ×1