小编kay*_*uhb的帖子

我应该在哪里将api密钥存储在rails3中?

在rails3中存储/检索API密钥的最佳实践是什么?

我应该创建自己的应用程序yaml并通过那里访问它吗?如果是这样,怎么样?

对不起noob问题...

app-config api-key ruby-on-rails-3

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

在 django admin 中将 json 文本显示为友好列表

我在模型中有一个 JSONField ( http://djangosnippets.org/snippets/1478/ ),我试图找出向管理员用户显示数据而不是 json 的最佳方式。

有谁知道在 django admin 中执行此操作的最佳方法?

例如,我想

{u'field_user_name': u'foo bar', u'field_email': u'foo@bar.com'}

显示为

field_user_name = foo bar
field_email = foo@bar.com
Run Code Online (Sandbox Code Playgroud)

django json django-admin

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

Django管理GenericForeignKey小部件

我正在创建一个Django应用程序,其中所有模型可以按用户设置的顺序相互关联.我正在使用GenericForeignKeys设置所有这些.踢球者是我需要能够支持这些类型的关系/管理员的多个集合.因此,一个对象可以具有多个相关对象的集合.

有没有人知道这种情况下一个好的GenericForeignKey小部件?优选地,它将是填充管理表单的自动完成搜索,因为我最终可能具有大量对象.

这是我的应用程序的代码,以更好地了解我的意思.

from django.contrib import admin
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django import forms


# Models
class Base(models.Model):
    title = models.CharField(max_length=255)

    class Meta:
        abstract = True

    def __unicode__(self):
        return self.title

class Related(Base):
    """ A generic relationship model for relating resources.
    """
    order = models.IntegerField(blank=True, null=True)
    limit = models.Q(model = 'Apple') | models.Q(model = 'Orange') | models.Q(model = 'Pear') 

    content_type = models.ForeignKey(ContentType, related_name="related_%(class)s")
    object_id = models.PositiveIntegerField(db_index=True)
    object = generic.GenericForeignKey()

    related_content_type = models.ForeignKey(ContentType, …
Run Code Online (Sandbox Code Playgroud)

django django-admin django-widget

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