是否可以从数据库刷新django对象的状态?我的意思是行为大致相当于:
new_self = self.__class__.objects.get(pk=self.pk)
for each field of the record:
setattr(self, field, getattr(new_self, field))
Run Code Online (Sandbox Code Playgroud)
更新:在跟踪器中找到了重新打开/未修正的战争:http://code.djangoproject.com/ticket/901 .还是不明白为什么维护者不喜欢这个.
我的Component样子
import React, {PropTypes} from 'react';
import TransactionListRow from './TransactionListRow';
import {Table, TableBody, TableHeader, TableHeaderColumn, TableRow} from 'material-ui/Table';
const TransactionList = ({transactions}) => {
return (
<Table>
<TableHeader displaySelectAll={false}>
<TableRow>
<TableHeaderColumn>Name</TableHeaderColumn>
<TableHeaderColumn>Amount</TableHeaderColumn>
<TableHeaderColumn>Transaction</TableHeaderColumn>
<TableHeaderColumn>Category</TableHeaderColumn>
</TableRow>
</TableHeader>
<TableBody>
{transactions.map(transaction =>
<TransactionListRow key={transaction.id} transaction={transaction}/>
)}
</TableBody>
</Table>
);
};
TransactionList.propTypes = {
transactions: PropTypes.array.isRequired
};
export default TransactionList;
Run Code Online (Sandbox Code Playgroud)
测试是
import {mount} from 'enzyme';
import TransactionList from './TransactionList';
import {TableHeaderColumn} from 'material-ui/Table';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
describe("<TransactionList />", ()=> {
it('renders …Run Code Online (Sandbox Code Playgroud) 使用银色搜索器如何忽略多个目录?
我试过ag foo --ignore-dir dir1,dir2但它不起作用.
我正在使用Jquery Server端数据表,并且无法使页面2 +上的分页工作.
我有200条记录.第一页显示50.当我单击页面底部的分页编号时,它导航到第2页,但第2页为空.
我在同一个应用程序(但另一个表)中使用非服务器端数据表,它工作正常.
除了分页之外,选择每页显示的#of记录的选择菜单不起作用,并且列排序不起作用.
搜索工作正常
我正在使用:"1.12.4"Rails 5 DataTables 1.10.16
index.json.jbuilder
json.draw params[:draw]
json.recordsTotal @cooks.length
json.recordsFiltered @cooks.length
json.data do
json.array! @paginated do |cook|
json.DT_RowClass "js-cook-row js-cook-row-#{donor.id}"
if browser.device.mobile?
json.partial! 'cooks/mobile_data', cook: cook, project: @project
else
json.partial! 'cooks/desktop_data', cook: cook, project: @project
end
end
end
Run Code Online (Sandbox Code Playgroud)
带桌子的页面(苗条)
table.table.table-striped.table-bordered.table-hover.js-cook-table.cooks-table.dataTables-example.small-font.kitchen-table id="#{table_id}" data-toggle="table" width="100%"
thead
tr
- if source == RouteSourceConsts::WIZARD
th.updated-th data-field="cook-checkbox"
th.cook-category data-field="given" data-sortable="true" = t('cooks.table_title.given')
th.cook-vendor data-field="cook_name" data-sortable="true" = t('cooks.table_title.name')
th data-field="recipes" = t('cooks.table_title.recipes')
th data-field="helper" data-sortable="true" = t('cooks.table_title.helper')
th.status-info-th data-field="status" …Run Code Online (Sandbox Code Playgroud) 我在 Postgres 中使用 DBeaver。我可以打开一个新的 sql 编辑器ctl+[。
但是我的 Postgres 中有多个数据库。如何让 sql 编辑器针对另一个数据库运行?以下不起作用
use <db name>;
select * from <table name>;
Run Code Online (Sandbox Code Playgroud)
在尝试为chrome创建源地图后,我从heroku收到以下警告http://blog.vhyza.eu/blog/2013/09/22/debugging-rails-4-coffeescript-and-sass-source-files -in-google-chrome / 它们表示什么,如果有的话,我应该改变什么?
我的gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
gem 'pg'
gem 'devise'
gem 'font-awesome-rails'
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass'
gem 'simple_form', git: 'https://github.com/plataformatec/simple_form.git'
gem 'carrierwave'
gem 'fog', '~> 1.3.1'
gem 'mini_magick'
gem 'rails_12factor'
gem 'friendly_id', '~> 5.0.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
gem 'bourbon'
group :development do
gem 'sass-rails-source-maps'
end
# Use …Run Code Online (Sandbox Code Playgroud) 有没有人知道如何将类simple_form从'controls'改为'form-control'.这是Bootstrap 3中的一个更改.我知道config/initializers/simple_form.rb和config/initializers/simple_form_bootstrap.rb中有很多选项,但我找不到我需要的东西.
config.wrappers :bootstrap, :tag => 'div', :class => 'control-group', :error_ class => 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper :tag => 'div', :class => 'controls' do |ba|
ba.use :input
ba.use :error, :wrap_with => { :tag => 'span', :class => 'help-inline' }
ba.use :hint, :wrap_with => { :tag => 'p', :class => 'help-block' }
end
end
Run Code Online (Sandbox Code Playgroud)
在上面你可以将'control-group'替换为'form-group',但我认为没有办法改变输入标签的类.
ruby-on-rails simple-form twitter-bootstrap twitter-bootstrap-3
我正在学习动画和panresponder apis in react native.使用React Native和源代码进行动画拖放
我想扩展示例,以便您可以拖动圆圈而无需重置它.目前,代码将圆圈设置回屏幕中心,并依赖于panresponders dX/dY值.
我最好的猜测是我必须改变一些东西 onPanResponderMove
onPanResponderMove: Animated.event([null, {
dx: this.state.pan.x,
dy: this.state.pan.y,
}]),
Run Code Online (Sandbox Code Playgroud)
我需要在源代码中进行哪些更改,以便在注释onPanResponderRelease逻辑时圆圈正确地拖动屏幕?
getTranslateTransform()?
我正在尝试使用 Fetch API 将照片文件上传到 S3 存储桶。尝试上传照片时,我在 POST 上收到 400 Bad Request。我正确获取了预先签名的帖子 url 和文件详细信息,但我相信我格式化 formData 的方式不正确。
我正在使用一个 html 文件输入,它使用 onchange 来运行 javascript 函数 handlePhoto。
html是
<input type="file" onchange="handlePhoto()" id="file_input"/>
Run Code Online (Sandbox Code Playgroud)
和 javascript 函数是
function handlePhoto(){
const file = document.getElementById('file_input').files[0]
let formData = new FormData()
fetch("/v1/photos/get_presigned_post/" , {
method: "GET"
})
.then(response => response.json())
.then(s3Result => {
const { url, fields } = s3Result;
Object.keys(s3Result.fields).forEach(key => {
formData.append(key, s3Result.fields[key]);
});
formData.append('acl', 'public-read');
formData.append('Content-Type', file.type);
formData.append("file", file);
fetch(url, {
method: "POST",
body: formData,
headers: …Run Code Online (Sandbox Code Playgroud) 我不小心创建了一个名为的文件:w.我设法通过使用zsh选项卡功能删除它.但我不能从我的git缓存中删除它.
git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: Gemfile
# modified: Gemfile.lock
# new file: config/newrelic.yml
#
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: :w
#
Run Code Online (Sandbox Code Playgroud)
然后
git rm :w
fatal: pathspec 'w' did not match any files
Run Code Online (Sandbox Code Playgroud) javascript ×2
ag ×1
amazon-s3 ×1
command-line ×1
datatables ×1
dbeaver ×1
django ×1
enzyme ×1
fetch-api ×1
filenames ×1
git ×1
heroku ×1
jquery ×1
material-ui ×1
python ×1
react-native ×1
reactjs ×1
sass ×1
server-side ×1
simple-form ×1
source-maps ×1
unix ×1