小编Jam*_*est的帖子

为什么在转换为字符串然后转换为符号时,空数组和哈希值的处理方式不同?

在Ruby中,为什么这两个操作对于空数组和哈希值是不同的?

空数组:

[].to_s.to_sym => :[] 
Run Code Online (Sandbox Code Playgroud)

空哈希:

{}.to_s.to_sym => :"{}"
Run Code Online (Sandbox Code Playgroud)

ruby

3
推荐指数
1
解决办法
80
查看次数

Nullable DecimalField在空白时返回'此值必须是十进制数'

我的模型中有一个类型的字段DecimalField.虽然我blank=True并null=True在选项中,当我的模型经过表单验证和字段为空,我得到一个错误"该值必须是一个十进制数." 可以DecimalField不是空的吗?我可以为这个字段设置默认值0,但我宁愿让它可以为空.

注意:此字段最初不可为空,但我通过南迁移更改了模型以使字段可为空.我仔细检查了数据库以确认该列是否为NULL?=不.

这是模型中的字段定义:

reqwest_max = models.DecimalField("Maximum $", max_digits=11, decimal_places=2, blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)

ModelForm定义是:

class ReqwestDetailsForm(ModelForm):
  details = forms.CharField(widget=forms.Textarea(attrs={'class':'span8'}),
                            label = 'What do you need help with?',
                            required=False)
  reqwest_max = forms.CharField(label = "Will Pay Up To $",
                                required=False)

  class Meta:
    model = Reqwest
    widgets = {
      'tags': TextInput(attrs={'size':75}),
    }
Run Code Online (Sandbox Code Playgroud)

python django django-models

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

Django South:在数据迁移后添加模型字段

每当我创建一个datamigration使用Django South(但尚未运行它),然后随后创建一个schemamigration向该迁移中涉及的模型添加新字段时,manage.py migrate任务就失败了datamigration.

原因是models.py文件的类定义包含一个datamigration无法识别的新字段定义.

有什么方法可以防止这种情况吗?

python django django-south

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

iOS模拟器不会与Calabash一起启动

我在项目中将Calabash安装为pod.gem本身是使用bundler安装的.当我尝试为我的Calabash目标运行黄瓜时,第一个功能启动,但只是挂起,模拟器永远不会启动:

$ bundle exec cucumber
Feature: Ensure Login and Oauth Screen Functionality

  Scenario: Verify Welcome Page                 # features/Sign_in.feature:3
Run Code Online (Sandbox Code Playgroud)

我安装的更多细节:

# xcode installation location
$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer

# xcode version
$ xcodebuild -version
Xcode 5.1.1
Build version 5B1008

# calabash version
$ bundle exec calabash-ios version
0.9.168

# calabash < 0.9.169 or Xamarin IDE users
# start your app manually in the simulator or from Xcode and then launch a console
$ bundle exec calabash-ios console
> server_version
{
                        "outcome" …
Run Code Online (Sandbox Code Playgroud)

calabash calabash-ios

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

如何让我的Django CSS在我的生产环境中正确呈现?

我试图在生产环境中部署Django应用程序,我似乎无法正确渲染CSS.在我当地的环境中它工作正常.在设置中,我已经设置:

STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
Run Code Online (Sandbox Code Playgroud)

在服务器上,我运行collectstatic将文件收集到以下文件夹中:

STATIC_ROOT = '/sites/thetweethereafter.com/public/static'
Run Code Online (Sandbox Code Playgroud)

网络服务器是nginx,我的nginx.conf是:

events {
    worker_connections  1024;
}
http {
    server {
      listen 80;
      server_name www.thetweethereafter.com;
      rewrite ^/(.*) http://thetweethereafter.com/$1 permanent;
    }

    server {
      listen 80;
      server_name thetweethereafter.com;

      access_log /sites/thetweethereafter.com/logs/access.log;
      error_log /sites/thetweethereafter.com/logs/error.log;

      location /static {
          autoindex on;
          root /sites/thetweethereafter.com/public/;
      }

      location / {
        proxy_pass http://127.0.0.1:29000;
      }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我直接浏览静态文件,我可以没问题.

http://thetweethereafter.com/static/css/styles.css

但是,当我加载引用其中一个文件的页面时,浏览器不会呈现它们.

http://thetweethereafter.com

我不能为我的生活弄清楚我做错了什么.我有很多其他项目以类似的方式设置,它们工作正常.我错过了什么?

python django nginx

0
推荐指数
1
解决办法
915
查看次数