Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
filter by default with now() and earlier djangorestframework

I'm passing date parameters from angualrjs controller to my restapi, now the date parameter is not specified so I need to filter by default with now() and earlier on parameter which I'm sending to restapi so if I'm understanding correctly filter should be in the get function on the view, probably, like I said probably because I'm in a dilemma on this one, and asking from someone to explain to me how can I do this. You can check my controller and view down bellow.

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")

]

ModelViewSet:

class LeadContactViewSet(viewsets.ModelViewSet):
    def get_queryset(self):
        queryset = LeadContact.objects.none()
        user = self.request.user
        if user.has_perm('vinclucms_sales.can_view_full_lead_contact_list'):
            queryset = LeadContact.objects.all()
        elif user.has_perm('cms_sales.can_view_lead_contact'):
            queryset = LeadContact.objects.filter(account_handler=user)
        return queryset

    # rest of the view below
    .....
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!