小编use*_*776的帖子

Django管理员在使用gunicorn Web服务器时缺少静态文件

当我运行我的项目时runserver,django admin显示静态文件.一切看起来都很漂亮.

但是当我使用gunicornWeb服务器运行我的项目时,找不到django管理员的静态文件:

Not Found: /
Not Found: /favicon.ico
Not Found: /static/admin/css/base.css
Not Found: /static/admin/css/login.css
Not Found: /static/admin/css/base.css
Not Found: /static/admin/css/dashboard.css
Run Code Online (Sandbox Code Playgroud)

为什么这些静态文件没有开箱即用?

我应该采取哪些步骤来为django admin提供静态文件gunicorn

我正在使用Django 1.9和python 3.4

django

4
推荐指数
1
解决办法
2276
查看次数

将内容垂直对齐到div的中间?

我有一个包含一些内容的div.它的高度为31px,在其内部,按钮的高度较小.

<div class="headerAndButton">
    <h3 class="h3">
        Click the button to the right
        <button>click me</button>
    </h3>
</div> 
Run Code Online (Sandbox Code Playgroud)

我有另一个没有按钮的标题.

<div class="headerAndButton">
    <h3 class="h3">No button here, I only want to have this header have the same vertical alignment, height and margin as the other header</h3>
</div>
Run Code Online (Sandbox Code Playgroud)

我想垂直对齐<h3>每个div中的文本.我试图通过以下SCSS解决问题:

.headerAndButton {
  margin-bottom: $space-300;

  h3 {
    min-height: 31px;
    vertical-align: bottom;

    button {
      margin-left: $space
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

vertical-align物业没有明显效果.没有底部的文字是顶部对齐的.另一个文本略低一些.如果我删除按钮,它也会变为顶部对齐.

如何使此标题具有相同的垂直对齐方式?我不擅长CSS,所以也许有更好的方法可以解决这个问题.

css sass

4
推荐指数
2
解决办法
1万
查看次数

为什么我需要在objective-c中使用@property关键字?

假设我的课上有以下公共方法:

- (BOOL)finished
{
    return _finished;
}
- (void)setFinished:(BOOL)aValue
{
    _finished = aValue;
}
Run Code Online (Sandbox Code Playgroud)

我是否还需要在课程中将finish设置为属性:

@property SomeClass *finished;
Run Code Online (Sandbox Code Playgroud)

我可能误会了@property,但对我而言,似乎我在重复自己.

  • 应该声明两种方法和一种@property或只是其中一种?

objective-c

4
推荐指数
1
解决办法
337
查看次数

JavaScript 类是对象吗?

我假设 ES6 类是一个对象,就像 JavaScript 中的“一切”都是对象一样。这是一个正确的假设吗?

javascript ecmascript-6

4
推荐指数
2
解决办法
2741
查看次数

TypeScript 无法编译,因为“any”的类型声明失去了类型安全性

我应该如何解决以下错误消息:

无法编译 /.../SoftwareLicenseCodes/index.tsx (14,20):“any”的类型声明失去类型安全性。考虑用更精确的类型替换它。此错误发生在构建期间,无法消除。

请看下面的代码:

import * as React from 'react';
import './SoftwareLicenseCodes.css';

interface SoftwareLicenseCodesProps {
}

interface SoftwareLicenseCodesState {
    count: string;
    oneTimeUsage: boolean;
    duration: string;
    validFrom: string;
    validTo: string;
    distributor: string;
    [key: string]: any;
}

class SoftwareLicenseCodes extends React.Component<SoftwareLicenseCodesProps, SoftwareLicenseCodesState> {
    constructor(props: SoftwareLicenseCodesProps) {
        super(props);

        this.state = {
            distributor: '',
            count:'',
            oneTimeUsage: false,
            duration: '',
            validFrom: '',
            validTo: ''
        };

        this.onInputChange = this.onInputChange.bind(this);
    }

    handleSubmit(event: React.FormEvent<HTMLFormElement>) {
        alert('submit');
        event.preventDefault();
    }

    onInputChange = (event: React.FormEvent<HTMLInputElement>) => {
        const value = …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs angular angular-ivy angular8

4
推荐指数
1
解决办法
5312
查看次数

当我尝试将消息 postMessage 回源时打字稿抱怨

这是我的代码

window.addEventListener('message', (e) => {
  e.source.postMessage('hi there, I hear you!', '*');
});
Run Code Online (Sandbox Code Playgroud)

这是错误:

[ts] 无法调用类型缺少调用签名的表达式。输入 '((message: any, targetOrigin: string, transfer?: any[]) => void) | ((message: any, transfer?: any[]) => void)' 没有兼容的调用签名。

当我检查postMessage它似乎是一种方法window并具有签名:

declare function postMessage(
    message: any,
    targetOrigin: string,
    transfer?: any[]
): void;
Run Code Online (Sandbox Code Playgroud)

这看起来很像我对我的呼号。那么我的代码有什么问题?

typescript

4
推荐指数
1
解决办法
2869
查看次数

使用TypeScript在create-react-app中的故事书

我试图在带有TypeScript的create-react-app中使用Stotybook而不会弹出。我已经知道,即使文档中未对此进行说明,这也是可能的。这是我使用的资源:

https://storybook.js.org/basics/introduction/

https://storybook.js.org/configurations/typescript-config/

https://github.com/wmonk/create-react-app-typescript/issues/405

我可以建立故事书,但它显示:

No Preview
Sorry, but you either have no stories or none are selected somehow.
Run Code Online (Sandbox Code Playgroud)

这是我所做的:

npx -p @storybook/cli sb init
npm install --save-dev react-docgen-typescript-webpack-plugin @storybook/addon-info @types/storybook__react awesome-typescript-loader
npm run storybook
Run Code Online (Sandbox Code Playgroud)

这是我从init storybook命令创建的内容中更改的代码:

tsconfig.js

...
"rootDirs": ["src", "stories"],
...
Run Code Online (Sandbox Code Playgroud)

.storybook / config.js

import { configure } from '@storybook/react';
// automatically import all files ending in *.stories.js
const req = require.context('../', true, /.stories.tsx$/);
function loadStories() {
  req.keys().forEach(filename => req(filename));
}
configure(loadStories, module);
Run Code Online (Sandbox Code Playgroud)

.storybook / webpack.config.js

const path …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs storybook

4
推荐指数
1
解决办法
1708
查看次数

做一个玩笑测试以在抛出任何错误时失败?

如何在抛出任何错误时使玩笑测试失败?

我已经尝试了一些,但还没有掌握语法。

test('getArcId => Error', async () => {
    await expect(client.getArcId('skynet')).rejects.toThrow();
});
Run Code Online (Sandbox Code Playgroud)

我收到错误消息

getArcId › getArcId => 错误

期望(收到)。拒绝。toThrow()

收到的函数没有抛出

但是,以下测试通过了,因此我打算测试的函数确实抛出了(至少就我对 throw 含义的理解而言):

test('getArcId => Error', async () => {
    await client.getArcId('skynet').catch(e => 
        expect(e.message).toBe('Command failure')
    );
});
Run Code Online (Sandbox Code Playgroud)

error-handling unit-testing typescript jestjs

4
推荐指数
3
解决办法
6606
查看次数

安排 cron 工作永远不会发生?

这是我的 CronJob 规范的一部分:

kind: CronJob
spec:
    schedule: #{service.schedule}
Run Code Online (Sandbox Code Playgroud)

对于特定环境,设置了 cron 作业,但我从不希望它运行。我可以写入一些值schedule:来导致它永远不会运行吗?

我还没有找到所有支持的语法的任何文档,但我希望是这样的:

@never 或者 @InABillionYears

cron kubernetes

4
推荐指数
2
解决办法
3275
查看次数

用于删除未定义项的过滤器未被 TypeScript 选取

在下面的代码中,我想不必undefined为filteredDevice添加类型注释。我认为一个被过滤的设备不应该是未定义的,因为我过滤掉了未定义的设备。

但是如果我删除undefined类型注释,TypeScript 会抱怨Type 'ICouchDBDocument | undefined' is not assignable to type 'ICouchDBDocument'.

devices
.filter((device: ICouchDBDocument | undefined) => Boolean(device)) //should filter away all undefined devices?
.map((filteredDevice: ICouchDBDocument | undefined) => { ... })
Run Code Online (Sandbox Code Playgroud)

如何更改我的代码,以便过滤器对类型注释产生影响?

typescript

4
推荐指数
1
解决办法
2071
查看次数