2016-12-06 20:38:43 +01:00
|
|
|
from urllib.request import urlopen
|
|
|
|
|
2018-11-04 19:03:20 +01:00
|
|
|
from django.http import HttpResponse, StreamingHttpResponse
|
2018-12-06 16:08:01 +01:00
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
2015-01-28 13:35:27 +01: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 09:33:58 +01:00
|
|
|
from .models import Person
|
|
|
|
|
|
|
|
|
|
|
|
def example_view(request):
|
|
|
|
return HttpResponse("example view")
|
|
|
|
|
|
|
|
|
2018-11-04 19:03:20 +01: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 09:33:58 +01:00
|
|
|
def model_view(request):
|
|
|
|
people = Person.objects.all()
|
2013-08-30 01:20:00 +02: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 09:33:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
def create_model_instance(request):
|
|
|
|
person = Person(name="emily")
|
|
|
|
person.save()
|
2019-02-09 22:27:32 +01:00
|
|
|
return HttpResponse()
|
2012-10-20 12:34:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
def environ_view(request):
|
2013-08-30 01:20:00 +02:00
|
|
|
return HttpResponse(
|
|
|
|
"\n".join("%s: %r" % (k, v) for k, v in request.environ.items())
|
2022-02-03 20:24:19 +01:00
|
|
|
)
|
2016-12-06 20:38:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
def subview(request):
|
|
|
|
return HttpResponse("subview")
|
|
|
|
|
|
|
|
|
|
|
|
def subview_calling_view(request):
|
2017-06-05 15:56:51 +02:00
|
|
|
with urlopen(request.GET["url"] + "/subview/") as response:
|
|
|
|
return HttpResponse("subview calling view: {}".format(response.read().decode()))
|
2016-12-06 20:38:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
def check_model_instance_from_subview(request):
|
2017-06-05 15:56:51 +02: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 16:08:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt
|
|
|
|
def method_view(request):
|
|
|
|
return HttpResponse(request.method)
|