所以我有我的TagStatus模型.我正在尝试为它制作一个ModelForm.但是,我的表单要求使用{{tag.name}}填充隐藏的输入.我一直在查看文档,我不知道如何使标记字段成为隐藏的输入.也许ModelForm不是要走的路?
models.py:
class TagStatus(models.Model):
user = models.ForeignKey(User, null=True, unique=True)
status = models.CharField(max_length=2, choices=tag_statuses)
tag = models.ForeignKey(Tag, null=True, blank=True)
def __unicode__(self):
return self.status
def save(self, *args, **kwargs):
super(TagStatus, self).save(*args, **kwargs)
class TagStatusForm(modelForm):
class Meta:
model = TagStatus
fields = ('status','tag')
widgets = {
'select': Select,
'tag': ???
}
Run Code Online (Sandbox Code Playgroud)
django views.py:
@login_required
def tags(request):
all_tags = Tag.objects.all()
context = base_context(request)
if request.method == 'POST':
if 'status_check' in request.POST:
status_form = TagStatusForm(request.POST)
#if request.is_ajax():
if status_form.is_valid():
status_form.save()
response = simplejson.dumps({"status": "Successfully changed status"}) …Run Code Online (Sandbox Code Playgroud) 我一直在玩这个,我觉得这很简单.我想要做的是将鼠标悬停在"新"标签上.一旦处于悬停状态,仅使用CSS将内容从"NEW"更改为"ADD".
body{
font-family: Arial, Helvetica, sans-serif;
}
.item{
width: 30px;
}
a{
text-decoration:none;
}
.label {
padding: 1px 3px 2px;
font-size: 9.75px;
font-weight: bold;
color: #ffffff;
text-transform: uppercase;
white-space: nowrap;
background-color: #bfbfbf;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
text-decoration: none;
}
.label.success {
background-color: #46a546;
}
.item a p.new-label span{
position: relative;
content: 'NEW'
}
.item:hover a p.new-label span{
display: none;
}
.item:hover a p.new-label{
content: 'ADD';
}Run Code Online (Sandbox Code Playgroud)
<div class="item">
<a href="">
<p class="label success new-label"><span class="align">New</span></p>
</a>
</div>Run Code Online (Sandbox Code Playgroud)
这是一个 …
我会让你加快速度.我正在尝试设置一个Windows开发环境.我已经成功安装了python,django和virtualenv + virtualenwrapper(windows-cmd安装程序)
workon env
Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(1,6,1, 'final',0)
>>> quit()
Run Code Online (Sandbox Code Playgroud)
但是当我运行时:python manage.py runserver从我的克隆存储库中我收到此错误:
Traceback (most recent call last)"
File "manage.py", line 2, in (module)
from django.core.management import execute_manager
ImportError: cannot import name execute_manager
Run Code Online (Sandbox Code Playgroud)
python和django都添加到我的系统变量PATH中:
...C:\Python27\;C:\Python27\Scripts\;C:\PYTHON27\DLLs\;C:\PYTHON27\LIB\;C:\Python27\Lib\site-packages\;
Run Code Online (Sandbox Code Playgroud)
我也用bash和powershell尝试了这个,但我仍然得到同样的错误.
这是一个与virtualenv相关的问题吗?Django依赖问题?让人惊讶.我该如何解决这个问题?帮助我Stackoverflow-kenobi你唯一的希望.
我正在使用react,我试图显示此错误消息,如果this.state.message === 'failed'.但我真的不确定为什么这个三元操作不起作用.我在这做错了什么?
render() {
...
<div className="row">
return (this.state.message === 'failed') ? ( => {
<div className="alert alert-danger" role="alert">
Something went wrong
</div>
})() : false;
}
</div>
Run Code Online (Sandbox Code Playgroud)
现在它只是return (this.state.message === 'failed') ? ( =>在html中显示
我正在尝试做的是在选中标签+复选框时显示并隐藏div.(仅限CSS)
因此,如果单击[签名](选中).隐藏自己(div.remove-check)并显示隐藏的输入(div #mail).我认为我的代码会很好,但事实并非如此.我究竟做错了什么?
我的代码:
HTML:
<div class="remove-check">
<label for="reveal-email" class="btn" style="width: 300px"><input type="checkbox" id="reveal-email" role="button" />Sign Up</label>
</div>
<br>
<div id="email">
<form id="email-form" class="nice" action="" method="post">
<input class="input-text required email" type="text" name="EMAIL" id="id_email" placeholder="Email" />
<input type="hidden" name="name" id="id_name_email">
<a class="btn" >Apply</a>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
input[type=checkbox]{
visibility: hidden;
}
input[type=checkbox]:checked ~ .remove-check{
display: none;
}
input[type=checkbox]:checked ~ #email{
display: block;
}
#email{
display: none;
}
Run Code Online (Sandbox Code Playgroud)
这是一个小提示,向您展示我正在与之合作.
提前谢谢你的帮助.
因此,这行代码抛出的内容类似于"Failed propType:无效的prop类型array预期" object.
为什么会这样?
这是我的JSON:
"student_records": [
{
"program": "PSCI-210",
"grade": 80
}
]
Run Code Online (Sandbox Code Playgroud)
JSX:
import React, { PropTypes } from 'react';
const StudentRecordPropTypes = {
studentRecordData: PropTypes.object.isRequired,
};
function StudentRecord(props) {
const Records = props.studentRecordData;
return (
<div>
{(Records || []).map(student_records => (
<ul>
<li>{student_records.program} : {student_records.grade} </li>
</ul>
))}
</div>
);
}
StudentRecord.propTypes = StudentRecordPropTypes;
export default StudentRecord;
Run Code Online (Sandbox Code Playgroud)
它显示正确.经过一些谷歌搜索,我意识到它寻找一个数组,但它实际上是一个对象.我的问题是我不知道如何解决它.如何删除此错误?
我希望能够在我的python字符串中使用unicode.比如我有一个图标:
icon = '▲'
print icon
Run Code Online (Sandbox Code Playgroud)
应该创建icon ='▲'
但它确实以字符串形式返回它: ▲
如何让这个字符串识别unicode?
提前谢谢你的帮助.
我正在尝试将click事件附加到已经存在的dom元素中。
<div class="logMe" data-log-id="{{ data.log }}"></div>
...
<div id="events"></div>
Run Code Online (Sandbox Code Playgroud)
我似乎无法在我的jquery click处理程序内访问vue方法。它会抛出logData is not defined。
new Vue({
el: '#events',
mounted() {
$('.logMe').on('click', function() {
const data = $(this).data('log-id');
this.logData(data); // throws logData is not defined
});
},
methods: {
logData(id) {
console.log(id); // never fires
... hit server
},
},
});
Run Code Online (Sandbox Code Playgroud)
如果有人知道将单击事件附加到.html元素的更好方法,那就太好了!但是,如何冒泡并找到我的vue方法?这是一个小提琴来说明
如果用户单击标记,则立即识别全文(数字和字符).
回报 Popular Tag %82
我试过了:
$tag.click(function(){
var $this = $(this);
var text = $this.text();
var num = text.parseInt();
num.remove();
alert(text)
});
Run Code Online (Sandbox Code Playgroud)
对数字不起作用.那我怎么才能得到这些字母呢?即:忽略两个数字和特殊字符(%)
小提琴!谢谢你的帮助!
如果声明工作,我似乎无法得到我的jsx es6反应..我做错了什么?
const otherVariables = doesntMatter;
return (
...
<div>
{if (props.student.length == null && props.teacher.length == null) => (
<p>empty</p>
) : (
<p>not empty</p>
)}
</div>
...
)
Run Code Online (Sandbox Code Playgroud)
如何检查两个阵列是否为空?