Mochinov

Untitled

Feb 28th, 2022 (edited)
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. САМ СЕЛЕКТОР !!!!
  2.  
  3. def get_source_of_payment_select(request):
  4.     """Используется для ajax запроса options для select"""
  5.  
  6.     context = json.loads(request.body.decode('utf-8'))
  7.     search_query = str(context.get('search_query', '')).strip()
  8.  
  9.     search_query = split_query(search_query)[:500]
  10.  
  11.     limit = str(context.get('limit', ReferenceBookSelectorFilter.ITEMS_PER_PAGE))
  12.     limit = safe_to_int(limit, ReferenceBookSelectorFilter.ITEMS_PER_PAGE)
  13.  
  14.     page = str(context.get('page', 1))
  15.     page = safe_to_int(page, 1)
  16.  
  17.     is_exact = context.get('exact', False)
  18.  
  19.     select_filter = ReferenceBookSelectorFilter(
  20.         page=page,
  21.         limit=limit,
  22.         request=request,
  23.         is_exact=is_exact,
  24.         search_query=search_query,
  25.         field_name='source_of_payment',
  26.         reference_books=LVLeadPaymentHistory.BASE_REFERENCE_BOOKS,
  27.     )
  28.  
  29.     return JsonResponse(select_filter.get_select_data())
  30.  
  31.  
  32.  
  33. Url path !!!!!
  34.     path(
  35.         r'ajax/source_of_payment_select',
  36.         csrf_exempt(source_of_payment_select.get_source_of_payment_select),
  37.         name='source_of_payment_select'
  38.     ),
  39.  
  40.  
  41.  
  42.             cls.get_formated_field(
  43.                 name='source_of_payment_field', field_type=cls.DataFormat.SELECT_AJAX, is_reference_book=True                
  44.                 is_reference_book=True,  reference_book_name = LVLeadPaymentHistory.BASE_REFERENCE_BOOKS, <- Вот тут
  45.                 url=reverse('source_of_payment_select'), cell_width=12, action=cls.AjaxActions.SELECT, is_sorting=True
  46.             ),
  47.  
  48.  
Add Comment
Please, Sign In to add comment