我正在尝试使用django-crispy-forms AuthenticationForm在django中显示带有登录视图的内置.我有问题继承AuthenticationForm - 我得到一个AttributeError.错误说'WSGIrequest' object has no attribute 'get'.这是我的表格:
class LoginForm(AuthenticationForm):
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(
Field('username', placeholder="username"),
Field('password', placeholder="password"),)
super(AuthenticationForm, self).__init__(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)
我认为这个错误与通过重定向获取的登录视图有关(我正在使用@login_required装饰器).有没有人对如何使用django-crispy-forms子类化内置表单有任何想法,并避免此错误?
我遇到了 ESLint 未检测到带有“no-unused-vars”规则的导入 React 组件的问题。我的组件已导入:
import MediaQuery from 'react-responsive';
Run Code Online (Sandbox Code Playgroud)
该组件在文件中进一步使用:
render() {
return (
<MediaQuery maxDeviceWidth={750}>
<div style={styles.iconMobileContainerRight} >
<i className="fa fa-chevron-right" style={styles.checkboxMobile} aria-hidden="true" ></i>
</div>
</MediaQuery>
);
}
Run Code Online (Sandbox Code Playgroud)
我的 .eslintrc.js 文件如下:
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single" …Run Code Online (Sandbox Code Playgroud) 我需要比较位于嵌套模板中的两个模板助手值.我想知道是否有一种简单的方法来比较{{#if}}语句中的两个模板助手(一个来自父模板),如下所示:
{{#each bids}}
{{#if bid.price===../job.price}}
<span>some text</span>
{{else}}
<span>some other text</span>
{{/if}}
{{/each}}
Run Code Online (Sandbox Code Playgroud)
如果你不能这样做,我想另一种选择是在每个块内的新模板中使用Template.parentData?我并不反对这一点,如果可能的话,我上面概述的方式会更快更简单.谢谢.
我使用FlowRouter /流星有反应,我想传递一个FlowRouter.go方法的反应按钮,按下按钮时,浏览到一个新的一页.我想这样做是为了保持按钮作为可重复使用的组件,但我在努力搞清楚如何通过FlowRouter.go方法为无状态的功能组件.这是我现在拥有的简化版本:
import React, { Component } from 'react';
import { FlowRouter } from 'meteor/kadira:flow-router';
const ParentComponent = () => {
// define text and styles here
return (
<div>
<Button text={text} style={styles} action={FlowRouter.go("Register")}/>
</div>
);
}
Run Code Online (Sandbox Code Playgroud)
然后我的按钮组件:
import React, { Component } from 'react';
// Call to action button
const Button = ({text, style, action}) => {
return (
<button className="btn" style={style} onClick={() => action()}>
{text}
</button>
);
}
Button.propTypes = {
text: React.PropTypes.string.isRequired,
style: React.PropTypes.object,
action: React.PropTypes.func
}; …Run Code Online (Sandbox Code Playgroud) 我的Meteor模板之一中有一个select输入,它具有与每个select选项相关的三段数据。我正在尝试将所有三个数据(作为对象)发送到新模板,该模板通过Blaze API在用户选择后触发的“更改”事件上呈现。我的印象是可以使用Blaze.getData方法执行此操作,但是它似乎对我不起作用。我想知道是否有人使用此方法有经验,并且可能能够帮助我进行故障排除。
我设置了一个MeteorPad,并提供了我在此处尝试执行的操作的示例:http ://meteorpad.com/pad/69XGm5nWPutg8an7T/Select%20Item
另外,这是相关的“更改”事件代码:
Template.selectItem.events({
'change .select_item': function(event) {
event.preventDefault();
var view = Blaze.getView(event.target);
console.log(view); // me debugging
var item = Blaze.getData(view);
console.log(item); // me debugging
Blaze.renderWithData(Template.selectedResults, item, document.getElementById('results'));
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个角度组件模板,我想将title其@Input()注入,显示为:
<div class="title" >
{{ title }}
</div>
Run Code Online (Sandbox Code Playgroud)
如何title使用 ng2-translate 的管道将翻译注入到父组件中,如下所示:
<title-component
[title]="{{ 'KEY' | translate }}"
></title-component>
Run Code Online (Sandbox Code Playgroud)
我想将翻译后的字符串动态传递给子组件,但我希望避免将翻译服务注入到组件的构造函数中,并尽可能将所有内容保留在模板中。谢谢
javascript ×4
meteor ×3
meteor-blaze ×2
reactjs ×2
spacebars ×2
angular ×1
atom-editor ×1
django ×1
eslint ×1
flow-router ×1
linter ×1
python ×1
templates ×1