On Sun, Oct 30, 2011 at 8:38 PM, Kiril <karaatana...@gmail.com> wrote:
> Hello guys, > > in the past few months I have been developing a simple web site using > Django. I found Django amazing and mature framework for my needs. I am > now about to publish it in public hosting. > > To my dismay the erro info I have included in Http404 calls is wasted > by Django and cannot make it's way ot the handler404 and consequently > to the 404.html template. > > Here is example code from my views.py: > > #is user logged in > if not request.user.is_authenticated(): > raise Http404(_("It is not allowed to post anonymous comments")) > > Now I want to display the localized message in the 404.html but it > seems this does not make it to the handler404 view. > > Here is what I found in the Django sources - > django.core.handlers.base.get_response: > > except http.Http404, e: > logger.warning('Not Found: %s' % request.path, > extra={ > 'status_code': 404, > 'request': request > }) > if settings.DEBUG: > from django.views import debug > response = debug.technical_404_response(request, > e) > else: > try: > callback, param_dict = resolver.resolve404() > response = callback(request, **param_dict) > except: > > > As can be clealry seen the exception "e" is only passed ot the DEBUG > handler but no to the production one "callback". > > My feature request is to add keyword argument param_dict "exception" > with the value of the Http404 exception "e" that is passed over to the > handler404 code. I can make this fix in my local deployment but it is > not possible to edit my hodting provider Django instance. > > This will help communicate the details of the 404 errors to end users. > Same could be applied few lines below in the handler for > exceptions.PermissionDenied. > > I hope this resonates with the development concepts of Django and this > small fix can make its way in to follow on release. > > > > > -Kiril K > > But why you return HTTP 404 (Not found) error in case your user is not authenticated? Not found errors are designed to handle situations where document or page is not present on the server. It has nothing to do with user authentication. Please also see: https://docs.djangoproject.com/en/dev/topics/auth/ for django and authentication usage patterns. Also note that one line below that block you've cited is code path for handling PermissionDenied exception. Mateusz Marzantowicz -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.