Python django.views.defaults.page_not_found() Examples

The following are 5 code examples of django.views.defaults.page_not_found(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module django.views.defaults , or try the search function .
Example #1
Source File: __init__.py    From wagtail with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def display_custom_404(view_func):
    @functools.wraps(view_func)
    def wrapper(request, *args, **kwargs):
        try:
            return view_func(request, *args, **kwargs)
        except Http404:
            return page_not_found(request, '', template_name='wagtailadmin/404.html')

    return wrapper 
Example #2
Source File: urls.py    From edx-analytics-dashboard with GNU Affero General Public License v3.0 5 votes vote down vote up
def debug_page_not_found(request):
    return defaults.page_not_found(request, AttributeError('foobar')) 
Example #3
Source File: views.py    From product-definition-center with MIT License 5 votes vote down vote up
def handle404(request):
    if 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        return HttpResponse(json.dumps(handlers.NOT_FOUND_JSON_RESPONSE),
                            status=status.HTTP_404_NOT_FOUND,
                            content_type='application/json')

    if django_version < LooseVersion('1.9'):
        return defaults.page_not_found(request)
    else:
        exc_class, exc, tb = sys.exc_info()
        return defaults.page_not_found(request, exc) 
Example #4
Source File: views.py    From hypha with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def page_not_found(request, exception=None, template_name='apply/404.html'):
    if not request.user.is_authenticated:
        template_name = '404.html'
    return defaults.page_not_found(request, exception, template_name) 
Example #5
Source File: views.py    From esdc-ce with Apache License 2.0 5 votes vote down vote up
def page_not_found(request):
    """
    Custom 404 handler.
    """
    if request.path.startswith('/api/'):
        return HttpResponseNotFound('Resource not found', content_type='application/json')
    return defaults.page_not_found(request)