默认情况下使用now()和之前的djangorestframework进行过滤

时间:2017-04-24 10:31:11

标签: django django-rest-framework django-queryset

我将日期参数从angualrjs控制器传递到我的restapi,现在没有指定date参数所以我需要默认过滤now()和更早的参数,我发送给{{ 1}}所以,如果我正确理解过滤器应该在视图上的get函数中,可能就像我说的那样可能是因为我在这个问题上处于两难境地,并且要求某人向我解释我该怎么做这个。您可以查看我的restapi并向下查看。

controller

ModelViewSet:

app = angular.module 'cms.sales'

app.controller 'FilterContactsListCtrl', ['$scope', '$http',
  ($scope, $http) ->
    savedSuccessMessage = "Contact leads list was updated"
    savedFailMessage = "Failed to update contact leads list"
    $scope.selectDate = null

    $scope.init = (nextSelectedDate)->
      if nextSelectedDate
        $scope.selectDate = nextSelectedDate
      else
        $scope.selectDate = ""


    $scope.doAction = () ->
      data = {
        select_date: $scope.selectDate
      }
      $http.post("/api/sales/lead_contact/", data).then(
        nextContactListUpdateSuccess, nextContactListUpdateFailed
      )

    nextContactListUpdateSuccess = ()->
      ClientNotifications.showNotification("Success", "Contact Leads list page was updated", "success")

    nextContactListUpdateFailed = () ->
      ClientNotifications.showNotification("Alert", "Failed to update contact leads list page", "alert")

]

0 个答案:

没有答案