Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda