2016-12-07 03:38:43 +08:00
|
|
|
from urllib.request import urlopen
|
|
|
|
|
2018-11-05 02:03:20 +08:00
|
|
|
from django.http import HttpResponse, StreamingHttpResponse
|
2018-12-06 23:08:01 +08:00
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
2015-01-28 20:35:27 +08:00
|
|
|
|
Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-22 16:33:58 +08:00
|
|
|
from .models import Person
|
|
|
|
|
|
|
|
|
|
|
|
def example_view(request):
|
|
|
|
return HttpResponse('example view')
|
|
|
|
|
|
|
|
|
2018-11-05 02:03:20 +08:00
|
|
|
def streaming_example_view(request):
|
|
|
|
return StreamingHttpResponse((b'I', b'am', b'a', b'stream'))
|
|
|
|
|
|
|
|
|
Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-22 16:33:58 +08:00
|
|
|
def model_view(request):
|
|
|
|
people = Person.objects.all()
|
2013-08-30 07:20:00 +08:00
|
|
|
return HttpResponse('\n'.join(person.name for person in people))
|
Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for `contrib.admin`. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2011-12-22 16:33:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
def create_model_instance(request):
|
|
|
|
person = Person(name='emily')
|
|
|
|
person.save()
|
2012-10-20 18:34:50 +08:00
|
|
|
return HttpResponse('')
|
|
|
|
|
|
|
|
|
|
|
|
def environ_view(request):
|
2013-08-30 07:20:00 +08:00
|
|
|
return HttpResponse("\n".join("%s: %r" % (k, v) for k, v in request.environ.items()))
|
2016-12-07 03:38:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
def subview(request):
|
|
|
|
return HttpResponse('subview')
|
|
|
|
|
|
|
|
|
|
|
|
def subview_calling_view(request):
|
2017-06-05 21:56:51 +08:00
|
|
|
with urlopen(request.GET['url'] + '/subview/') as response:
|
|
|
|
return HttpResponse('subview calling view: {}'.format(response.read().decode()))
|
2016-12-07 03:38:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
def check_model_instance_from_subview(request):
|
2017-06-05 21:56:51 +08:00
|
|
|
with urlopen(request.GET['url'] + '/create_model_instance/'):
|
|
|
|
pass
|
|
|
|
with urlopen(request.GET['url'] + '/model_view/') as response:
|
|
|
|
return HttpResponse('subview calling view: {}'.format(response.read().decode()))
|
2018-12-06 23:08:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
|
|
def method_view(request):
|
|
|
|
return HttpResponse(request.method)
|