mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-03-29 11:20:30 +00:00
The old multiprocessing support was hard to maintain. Since signing and caching are part of `django.core` there is really no need to stick to our own solution. As a result multimachine support and security are now always in place. Fields are stored in Django's cache. The default cache used by select2 is called 'default' but can be cachanged overwriting the setting `SELECT2_CACHE_BACKEND`. Recommended cache backends are memcached, redis or a DB-cache. Refactored AutoResponseView The main reason for this refactoring is the fact that the pagingnation was slow. I dropped major parts of the initial code and wrote a more django-like-approach. Noteabley: - get_results now retuns a QuerySet - This commit drops django 1.6 support in favour of the JsonResponse (Backporting is possible).
17 lines
505 B
Python
17 lines
505 B
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import unicode_literals
|
|
|
|
import json
|
|
|
|
from django.http import HttpResponse
|
|
from django.views.generic import FormView
|
|
|
|
|
|
class TemplateFormView(FormView):
|
|
template_name = 'form.html'
|
|
|
|
|
|
def heavy_data(request):
|
|
numbers = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five']
|
|
results = [{'id': index, 'text': value} for (index, value) in enumerate(numbers)]
|
|
return HttpResponse(json.dumps({'err': 'nil', 'results': results}), content_type='application/json')
|