def get(self, request, *args, **kwargs): self.object_list = self.get_queryset() regions = None query = request.GET.get('query') if query is not None: self.object_list = safe_queryset_and( self.object_list, self.model.objects._search(query)) regions = {} context = self.get_context_data( object_list=self.object_list, regions=regions) response = self.render_to_response(context) if query is not None: response.render() data = changed_regions(regions, ['object_list']) data['!keep'] = True # Keep modal open return HttpResponse( json.dumps(data), content_type='application/json') return response
def form_valid(self, form): self.object = form.save() regions = DetailView.render_regions(self) data = {'!form-errors': {}} data.update(changed_regions(regions, form.changed_data)) return HttpResponse(json.dumps(data), content_type='application/json')
def response_editlive(self, request, new_instance, form, formsets): regions = {} self.render_detail(request, { self.template_object_name: new_instance, 'regions': regions, }) return HttpResponse( json.dumps(changed_regions(regions, form.changed_data)), content_type='application/json')
def update_parent(self): regions = DetailView.render_regions( self, model=self.parent.__class__, object=self.parent) return HttpResponse( json.dumps(changed_regions(regions, [ '%s_set' % self.model.__name__.lower(), ])), content_type='application/json')
def response_add(self, request, instance, *args, **kwargs): regions = {} opts = self.parent_class._meta render(request, '%s/%s_detail.html' % (opts.app_label, opts.module_name), { 'object': getattr(instance, self.parent_attr), 'regions': regions, }) return HttpResponse( json.dumps(changed_regions(regions, [ '%s_set' % self.model.__name__.lower(), ])), content_type='application/json')
def get(self, request, *args, **kwargs): self.object_list = self.get_queryset() regions = None query = request.GET.get('query') if query is not None: self.object_list = safe_queryset_and( self.object_list, self.model.objects._search(query)) regions = {} context = self.get_context_data(object_list=self.object_list, regions=regions) response = self.render_to_response(context) if query is not None: response.render() data = changed_regions(regions, ['object_list']) data['!keep'] = True # Keep modal open return HttpResponse(json.dumps(data), content_type='application/json') return response
def picker(self, request): queryset = self.get_query_set(request) regions = None query = request.GET.get('query') if query is not None: queryset = safe_queryset_and(queryset, self.model.objects._search(query)) regions = {} response = self.render( request, self.get_template(request, 'picker'), self.get_context(request, { self.template_object_list_name: queryset, 'regions': regions, })) if query is not None: data = changed_regions(regions, ['object_list']) data['!keep'] = True # Keep modal open return HttpResponse(json.dumps(data), content_type='application/json') return response