Django Tastypie ModelResource:使用Json格式更新数据

时间:2016-02-23 04:52:48

标签: django tastypie

我是django tastypie modelresource的新手。这是我使用tastypie更新数据的代码。如何使用方法PUT以正确的方式编写代码。

class OrderAerialStatusResources(ModelResource):
    user_id = fields.CharField(attribute='user_id')

    def determine_format(self, request):
        return 'application/json'

    class Meta:
        queryset = Order.objects.all()
        list_allowed_methods = ['get','put']
        resource_name = 'order_status'
        authorization = Authorization()
        fields = ['id','status']

        filtering = {
            "id": ALL,
        }

1 个答案:

答案 0 :(得分:0)

public class LinkedStringLog implements StringLog {
  private LLStringNode head;
  private int numOfEntries;


  public LinkedStringLog() {//constructor
    head = null;
    numOfEntries = 0;
    }


  public void delete(String target){//deletes all entries of target

    LLStringNode current = head;
    LLStringNode prev = head;

    for (int i = 0; i < numOfEntries; i++) {
        prev = current;
        current = current.getNext();

        if (target.equals(current.getValue())){
            prev.setNext(current.getNext());
            current.setNext(null);
            numOfEntries--;

        }
    }