In your first exemple, you return a class but in your second exemple
you return an instance of the class. That might explain the difference
you notice.
The documentation on HttpResponseBadRequest mention it is used like an
HttpResponse object and part 3 of the django tutorial show how to
render a template in a HttpResponse object:
https://docs.djangoproject.com/en/1.10/intro/tutorial03/#write-views-that-actually-do-something
2017-01-03 12:22 GMT+01:00 Sergiy Smertelny <smertelny@gmail.com>:
> There is some strange problem. When I do like this
>
> def error_page(request):
> return HttpResponseBadRequest
>
> it raises My custom error page that I listed in main URLconf. But when I
> pass and exception there - I got just a blank page with the text of
> exception. For example, view is something like this:
>
> def error_page(request):
> return HttpResponseBadRequest('The error text')
>
> And I get a blank page with the "The error text" text in body, but not my
> custom error page. How can I make Django use my Error page Template, but
> with error text?
>
> I am using Python 3.5 and Django 1.10.4
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/29e5659d-bbb7-4bc5-b0f7-e491cb24f6bc%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
Cordialement, Coues Ludovic
+336 148 743 42
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEuG%2BTYL4x65DYQXq3_PDuiukm26vnh40ccbfPp%2BkbK9r8KNoQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment