小编Pie*_*NAY的帖子

Django - 用户全名为unicode

我有许多模型链接到User,我希望我的模板总是显示他的full_name(如果可用).有没有办法改变默认值User __unicode__()?或者还有另一种方法吗?

我有一个可以定义的配置文件模型,我__unicode__()应该将所有模型链接到它吗?对我来说似乎不是一个好主意.


想象一下,我需要显示这个对象的表单

class UserBagde
    user = model.ForeignKey(User)
    badge = models.ForeignKey(Bagde)
Run Code Online (Sandbox Code Playgroud)

我将不得不选择__unicodes__每个对象的盒子,不是吗?
如何在用户名中使用全名?

python django django-models django-users

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

Google Chart API - Pie legend.textStyle颜色

从饼图的官方示例开始.
我无法改变传奇色彩.

'legend.textStyle': { 'color': 'gray' }  
Run Code Online (Sandbox Code Playgroud)

没有考虑到.
请查看小提琴
我做错了什么?

javascript google-visualization pie-chart

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

Django - 管理员:list_display TextField

我想要显示的前10个字符TextFieldlist_display.
是否可以在管理界面?

django django-admin

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

jQuery - 插件选项默认extend()

按照良好的jQuery插件/创作说明,我有一个小问题

(function($){

  // Default Settings
  var settings = {
    var1: 50
  , var2: 100
  };

  var methods = {
    init : function (options) {
      console.log(settings);
      settings = $.extend(options, settings); // Overwrite settings
      console.log(settings);
      return this;
    }
  , other_func: function () {
      return this;
    }
  };

  $.fn.my_plugin = function (method) { 
    if (methods[method]) {
      return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || ! method) {
      return methods.init.apply(this, arguments);
    } else {
      $.error('Method ' +  method …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-plugins

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

Django - 更改语言环境的时间格式

我正在开发一个使用l10n的项目.
如果我将区域设置设置为EN并尝试显示时间(08:00),我会得到:

8 a.m.
Run Code Online (Sandbox Code Playgroud)

如果我将语言环境设置为FR,我会得到:

08:00:00
Run Code Online (Sandbox Code Playgroud)

但它应该是这样的:

8h
Run Code Online (Sandbox Code Playgroud)

我为什么要这种格式?我怎样才能获得正确的格式?

django localization django-templates

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

git-shell - 新的存储库

我有一个具有专用git用户和存储库的服务器
我正在尝试使用该git-shell方法允许我的开发人员在几个项目上工作.

我即将把我的git用户的shell更改为git-shell
如果我这样做,我将无法再与标准shell连接(这就是想法).

问题:那么我将如何创建新的存储库?

我是否每次都会与sudoer建立联系并创建回购然后将其展开?

git repository git-shell

7
推荐指数
2
解决办法
6804
查看次数

pod安装 - Podfile.lock已更新

我刚刚克隆了一个锁定了几个pod的项目.

经过pod install我的Podfile.lock被修改.

为什么?

是不是应该只在我这样做时更新pod update


Podfile

platform :ios, '6.0'
pod 'SVProgressHUD',    '~> 0.9'
pod 'Reachability',     '~> 3.1.0'
pod 'UIDeviceAddition', '~> 1.0'
pod 'CorePlot',         '~> 1.3'
pod 'RestKit',          '~> 0.20'
pod 'ZipArchive',       '~> 1.1.0'
Run Code Online (Sandbox Code Playgroud)

^ - 没有改变 - ^

DIFF

index c82dc53..e408a71 100644
--- a/Podfile.lock
+++ b/Podfile.lock
@@ -1,5 +1,5 @@
 PODS:
-  - AFNetworking (1.3.2)
+  - AFNetworking (1.3.4)
   - CorePlot (1.3)
   - Reachability (3.1.1)
   - RestKit (0.20.3):
@@ -32,14 +32,14 @@ DEPENDENCIES:
   - ZipArchive …
Run Code Online (Sandbox Code Playgroud)

cocoapods

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

AFNetworking为可信证书提供公钥

我使用AFNetworking 2.3.1,我有一个值得信赖的证书,我想用它来固定公钥.

我有crt,key,pfx文件,所以我想我必须将它们添加到我的包.

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]
    initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation,
        id responseObject) {
    NSLog(@"Success");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    return [self processError:[operation response]];
}];
[operation start];
Run Code Online (Sandbox Code Playgroud)

现在我如何告诉AFNetworking使用该AFSSLPinningModePublicKey模式?
(我没看到setSSLPinningMode方法AFHTTPRequestOperation)

我如何告诉AFNetworking使用添加的密钥?我在文档中找不到任何示例.

objective-c nsurlconnection afnetworking afnetworking-2

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

Django - 来自App目录的静态文件

在开发环境中,我想使用app目录中的静态文件.

#settings.py

SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
STATIC_ROOT = (os.path.join(SITE_ROOT, 'static_files/'))
STATIC_URL = '/static/'
STATICFILES_DIRS = (
  os.path.join(SITE_ROOT, 'static/'),
)
STATICFILES_FINDERS = (
  'django.contrib.staticfiles.finders.FileSystemFinder',
  'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATE_CONTEXT_PROCESSORS = (
#...
  'django.core.context_processors.static',
#...
)
INSTALLED_APPS = (
#...
  'django.contrib.staticfiles',
#...
)
Run Code Online (Sandbox Code Playgroud)

我可以找到我的静态文件,如果位于,/static/css/file.css但不是如果在an_app/static/css/file.css.

python django static-files django-settings

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

大多数标准日历交换数据格式

我有一个带有调度程序应用程序的系统(php/MySQL).

我即将创建一项服务,允许用户从outlook,google,sunbird,...阅读他们的日历.

我想知道今天交换日历数据的最标准格式是什么.

这是ical吗?

icalendar calendar scheduling google-calendar-api

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