我在vimle的帮助下安装了You Complete Me.我第一次使用它时,建议的单词完全不可读.它们有深紫色背景和黑色字体颜色.然后我在quora上看到了这个帖子,现在改变了我的.vimrc.我的.vimrc目前看起来像这样.
set tabstop=2
highlight Comment ctermfg=lightblue
highlight Pmenu ctermfg=2 ctermbg=3 guifg=#ffffff guibg=#000000
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
Run Code Online (Sandbox Code Playgroud)
不幸的是,建议的单词显示如下

我读不太清楚,想改变它但不知道怎么做.我认为我目前的设置会给我白色前景和黑色背景.
安装这个插件后,我也有4个而不是2个缩进..我已经尝试了这个,但它没有为我服务.我怎么能改变这个?
我想写一个注册用户的表单.我想实现一个密码匹配,用户必须输入两次密码.这是我目前的表格:
from django import forms
from passwords.fields import PasswordField
class AccountForm(forms.Form):
email = forms.EmailField(max_length=255)
username = forms.CharField(max_length=40)
password = PasswordField(label="Password")
password_confirm = PasswordField(label="Password")
Run Code Online (Sandbox Code Playgroud)
在我看来,我想检查验证,如果某些内容无效,我想在模板中打印特定的错误.这是我的观点的当前状态:
def signup(request):
if request.method == 'POST':
form = AccountForm(request.POST)
if form.is_valid():
email = form.cleaned_data['email']
username = form.cleaned_data['username']
password = form.cleaned_data['password']
password_confirm = form.cleaned_data['password_confirm']
if password != password_confirm:
print("Password don't match")
#Account.objects.create_user(email, password, username = username)
else:
print(form.errors)
form = Account()
return render(request, 'authentication/auth.html', {'signup': form})
Run Code Online (Sandbox Code Playgroud)
现在我的目标是将表单错误传递给模板.我检查例如password与password_confirm变量的匹配.如果它们不匹配,我希望它在模板中可见.你们知道如何将我的自定义表单错误/验证添加到我的表单中并在我的模板中显示这些错误吗?
我想制作一个用于过滤搜索的表单,不需要任何字段.例如,给出此代码:
models.py:
class Message(models.Model):
happened = models.DateTimeField()
filename = models.CharField(max_length=512, blank=True, null=True)
message = models.TextField(blank=True, null=True)
dest = models.CharField(max_length=512, blank=True, null=True)
fromhost = models.ForeignKey(Hosts, related_name='to hosts', blank=True, null=True)
TYPE_CHOICES = ( (u'Info', u'Info'), (u'Error', u'Error'), (u'File', u'File'), (u'BPS', u'BPS'),)
type = models.CharField(max_length=7, choices=TYPE_CHOICES)
job = models.ForeignKey(Jobs)
Run Code Online (Sandbox Code Playgroud)
views.py:
WHEN_CHOICES = ( (u'', ''), (1, u'Today'), (2, u'Two days'), (3, u'Three Days'), (7, u'Week'),(31, u'Month'),)
class MessageSearch(ModelForm): #Class that makes a form from a model that can be customized by placing info …Run Code Online (Sandbox Code Playgroud) 我有一个表单,我想根据用户的决定隐藏或显示它。我在外部 javascript 文件中获得了以下功能:
function hide_element() {
$("form").hide();
};
function show_element() {
$("form").show();
};
Run Code Online (Sandbox Code Playgroud)
这就是我调用这些函数的方式:
<button type="submit" onclick="show_element;">show</button>
<button type="submit" onclick="hide_element;">hide</button>
<form>
...
</form>
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用。你知道为什么会这样吗?