V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
phjy007lt
V2EX  ›  Python

有玩Django Tastypie的同学嘛?来请教问题了

  •  
  •   phjy007lt · Dec 11, 2012 · 4573 views
    This topic created in 4896 days ago, the information mentioned may be changed or developed.
    最近在用django+Tastypie做一个东东,想请教些问题...

    想通过Api URL来post或者put数据(json)的时候,原先在Mdodel中定义时带有引用关系的字段(如Foreigney等)的信息该怎么填呢?

    不想用Tastypie默认的那套URL机制,该怎么弄呢...比如请求名为Tom的用户信息(假设Tom在Django数据库user表中的id是1)的话,要么是/api/v1/user/?username=Tom,要么是先/api/v1/user/1/(这种机制都首先知道Tom的id)。我想能不能直接用/api/v1/user/Tom/这样的形式呀?URL里直接跟username的话,方便多了,也直观多了。
    (看过Tastypie关于override_urls或prepend_urls等方面的东西,单感觉还是没咋明白)

    还有,就是Tastypie中的认证、和授权机制是怎么样的呢。。我不是太理解。。比如说,怎样实现只有Tom(id为1)才有权限请求获得/api/v1/user/1/的数据,而当Alice(id为2)请求/api/v1/user/1/时将返回空的数据。


    总之,想稍微深入点去,就感觉Tastypie的文档,貌似不是很好懂而且不是很全的样子...请教各位大神的感受和建议...
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5020 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 03:58 · PVG 11:58 · LAX 20:58 · JFK 23:58
    ♥ Do have faith in what you're doing.