小编nkn*_*knj的帖子

Bootstrap3中的列排序未按预期工作

我正在使用Bootstrap 3中的列排序进行一些实验,并遇到了这个问题.

我怎样才能达到以下顺序:

  • XS:123
  • SM:231
  • MD:312
  • LG:123

这就是我所拥有的:LG不工作和显示<blank>13而不是123

<div class="row">
   <div class="col-xs-4 col-sm-push-8 col-md-push-4 col-lg-pull-0">1</div>
   <div class="col-xs-4 col-sm-pull-4 col-md-push-4 col-lg-pull-0">2</div>
   <div class="col-xs-4 col-sm-pull-4 col-md-pull-8 col-lg-pull-0">3</div>
</div>
Run Code Online (Sandbox Code Playgroud)

responsive-design twitter-bootstrap twitter-bootstrap-3

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

更新时的Tastypie错误 - 字段已被赋予不是URI的数据,而不是字典相似且没有'pk'属性

当我尝试更新资源时,我不断收到此错误.

我想要更新的资源称为Message.它有一个外键帐户:

class AccountResource(ModelResource):
    class Meta:
        queryset = Account.objects.filter()
        resource_name = 'account'
        '''
        set to put because for some weird reason I can't edit 
        the other resources with patch if put is not allowed.
        '''
        allowed_methods = ['put']
        fields = ['id']


    def dehydrate(self, bundle):
        bundle.data['firstname'] = bundle.obj.account.first_name   
        bundle.data['lastname'] = bundle.obj.account.last_name
        return bundle
Run Code Online (Sandbox Code Playgroud)

class MessageResource(ModelResource):
    account = fields.ForeignKey(AccountResource, 'account', full=True)

    class Meta:
        queryset = AccountMessage.objects.filter(isActive=True)
        resource_name = 'message'
        allowed = ['get', 'put', 'patch', 'post']
        authentication = MessageAuthentication()
        authorization = MessageAuthorization()   
        filtering …
Run Code Online (Sandbox Code Playgroud)

api django rest tastypie

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

Tastypie - Queryset或过滤器

我正在使用tastypie而我遇到了一个问题.

我的问题:

用户可以发布消息,如果其他用户订阅了该用户,他们可以在其主页上看到这些消息.它完全像推特用户的推文和关注者看他们的推文.

我有一个公共api所有消息.
我可以使用过滤特定的用户消息?userid=1

解决问题的方法
糟糕:我可以使用过滤多个用户的消息(从而解决问题)
?userid__in=1&userid__=5&...

但这不是一个好方法,因为网址长度将增加到可能不允许的数量.(2000个字符)

有没有更好的方法呢?
有没有一种方法,我可以用request.user查询集做了加入?
或者我应该使用某种高级过滤

谢谢!

django tastypie

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

比较datetime对象python中的时间

我有一个奇怪的问题.

我正在运行一个django应用程序,在我的一个模型中,我有一个方法来比较用户给出的时间和模型db中存储的时间

因此,出于调试目的,我这样做.

print self.start
print start
print self.start.time < start.time

输出是:

2012-10-15 01:00:00+00:00
2012-10-22 01:01:00+00:00
False

这怎么可能?!?!?!

我在django shell和python cli中试过这个!两个都给我真实!具有相同的值.

多谢你们.

python django comparison datetime

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