小编tom*_*ber的帖子

Django:有没有办法让"日期范围独一无二"?

如果我的物品模型是:

class Item(models.Model):
    name = models.CharField(max_length=500)
    startDate = models.DateField("Start Date", unique="true")
    endDate = models.DateField("End Date")      
Run Code Online (Sandbox Code Playgroud)

每个项目都需要具有唯一的日期范围.例如,如果我创建一个项目有6月1日至6月8日的日期范围,我怎能和项目与正在创建6月3日的日期范围,以6月5日(或渲染模板逻辑错误)?

如果我能更好地澄清这个问题,告诉我!

python django django-templates django-models

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

当对象值是带有jQuery的对象数组时,遍历JSON

这是我的外部JSON:

{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 3}, "objects": [{"body": "this is copy text", "id": "1", "pub_date": "2011-05-04T12:23:26", "resource_uri": "/api/v1/entry/1/", "slug": "test-title-number-one", "title": "test title number one", "user": "/api/v1/user/1/"}, {"body": "this is the second test text", "id": "2", "pub_date": "2011-05-04T15:01:16", "resource_uri": "/api/v1/entry/2/", "slug": "second-test", "title": "Second test", "user": "/api/v1/user/1/"}, {"body": "item three", "id": "3", "pub_date": "2011-05-05T12:04:04", "resource_uri": "/api/v1/entry/3/", "slug": "item-3", "title": "item 3", "user": "/api/v1/user/1/"}]}
Run Code Online (Sandbox Code Playgroud)

这是我的JS:

$.ajax({url: "/api/v1/entry/?format=json", 
dataType: "json",
success: function(json) {
    $.each(json.objects[0], function(key, value) …
Run Code Online (Sandbox Code Playgroud)

javascript jquery json

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