2014-02-16 38 views
0

我只是讓自己進入前夕。偉大的框架,但我堅持與項目的鏈接。前夕很漂亮的鏈接項目,多個入口點

我有一個只允許item_methods的合同集合。

domain.com/contracts/19687176add597c50b13b4188fcafd6d

每個合同可以有n個信用票據,通過訪問:

domain.com/contracts/a78b1627f7858cc187bcad5d8abe19d3/creditnotes

- >所有信用票據清單。

列表中的每個信用票據有一個像這樣的鏈接:

_links": { 
    "self": { 
     "href": "domain.com/contracts/<regex(\"[a-f0-9]{32}\"):token>/creditnotes/DD001366" 

我想這是沒有內(沒有任何意義)的正則表達式一個漂亮的鏈接,我覺得這是最好有鏈接到信用票據項目是這樣的:

domain.com/creditnotes/DD001366

我試圖改變項配置,但至今沒有運氣:

creditnotes = { 
'url': 'contracts/<regex("[a-f0-9]{32}"):token>/creditnotes', 
'resource_title': 'creditnotes for contract token', 
'item_title': 'creditnote', 
'item_url': 'regex("[D0-9]{8}")', 
'item_lookup': True, 
'item_lookup_field': '_id', 

# We choose to override global cache-control directives for this resource. 
'cache_control': 'max-age=10,must-revalidate', 
'cache_expires': 10, 

# most global settings can be overridden at resource level 
'resource_methods': ['GET'], 
'item_methods': ['GET'], 
'pagination': False, 
# 'item_lookup_field': 'token', 

'schema': creditnotes_schema 

}

回答

0

是的,這是一個已知的問題與子資源。暫時您可能只需關閉HATEOASHATEOAS = False在您的設置文件中)即可解決此問題。

當它固定在開發分支上時,會爲此線程添加註釋。

+0

很好,謝謝提示信息。 – alanderex