def handler500(request):
    """
    An error handler which exposes the request object to the error template.
    """
    # Show admins a page with stacktrace
    if hasattr(request, 'user') and request.user.is_staff:
        return technical_500_response(request, *sys.exc_info())

    try:
        context = static(request)  # adds STATIC_URL
    except Exception as e:
        logging.error(e, exc_info=sys.exc_info(), extra={'request': request})
        context = {}

    try:
        context['exception_type'] = type(sys.exc_info()[1]).__name__
        context['exception'] = sys.exc_info()[1]
    except Exception:
        context['exception_type'] = 'Error'
        context['exception'] = 'Error getting exception'

    context['request'] = request

    template = loader.get_template('core/500.html')
    return HttpResponseServerError(template.render())
Example #2
0
def ajax_comment_tags(context, for_, target_object, user_picture=None):
    """
    Display the required ``<div>`` elements to let the Ajax comment functionality work with your form.
    """
    new_context = {
        'STATIC_URL': context.get('STATIC_URL', None),
        'target_object': target_object,
        'user_picture': user_picture,
    }

    # Be configuration independent:
    if new_context['STATIC_URL'] is None:
        try:
            request = context['request']
        except KeyError:
            new_context.update({'STATIC_URL': settings.STATIC_URL})
        else:
            new_context.update(context_processors.static(request))

    return new_context
    def get_context_data(self, parent_context, *tag_args, **tag_kwargs):
        """
        The main logic for the inclusion node, analogous to ``@register.inclusion_node``.
        """
        target_object = tag_args[0]  # moved one spot due to .pop(0)
        new_context = {
            "STATIC_URL": parent_context.get("STATIC_URL", None),
            "USE_THREADEDCOMMENTS": appsettings.USE_THREADEDCOMMENTS,
            "target_object": target_object,
        }

        # Be configuration independent:
        if new_context["STATIC_URL"] is None:
            try:
                request = parent_context["request"]
            except KeyError:
                new_context.update({"STATIC_URL": settings.STATIC_URL})
            else:
                new_context.update(context_processors.static(request))

        return new_context
    def get_context_data(self, parent_context, *tag_args, **tag_kwargs):
        """
        The main logic for the inclusion node, analogous to ``@register.inclusion_node``.
        """
        target_object = tag_args[0]  # moved one spot due to .pop(0)
        new_context = {
            'STATIC_URL': parent_context.get('STATIC_URL', None),
            'USE_THREADEDCOMMENTS': appsettings.USE_THREADEDCOMMENTS,
            'target_object': target_object,
        }

        # Be configuration independent:
        if new_context['STATIC_URL'] is None:
            try:
                request = parent_context['request']
            except KeyError:
                new_context.update({'STATIC_URL': settings.STATIC_URL})
            else:
                new_context.update(context_processors.static(request))

        return new_context
Example #5
0
"""myproject_new URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.template.context_processors import static
from django.conf.urls.static import static
from myproject_new import settings

urlpatterns = [
    path('admin/', admin.site.urls),
    path("myapp/", include('tuition_app.urls'))
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Example #6
0
    path('follow_author/', views.followAuthor),
    path('show_followed/', views.followed),
    path('cancel_follow/', views.cancel_follow),
    path('collect_paper/', views.collect_paper),
    path('verify_author/', views.veri_author),
    path('verify_success/', views.verify_success),
    path('check_user_info/', views.check_user_info),
    path('edit_user_info/', views.edit_user_info),
    path('hot_author/', views.hot_author),
    path('hot_paper/', views.hot_paper),
    path('hot_field/', views.hot_field),
    path('show_collected/', views.collected),
    path('cancel_collect/', views.cancel_collect),
    path('getAuthorInfoById', views.getAuthorInfoById),
    path('getPaperOfField', views.getPaperOfField),
    path('getAuthorOfField', views.getAuthorOfField),
    path('Authentication', views.Authentication),
    path('getBrowerHistory', views.getBrowerHistory),
    path('check_user', views.check_user),
    path('hot_orgz/', views.hot_orgz),
    path('hot_studyz/', views.hot_studyz),
    path('hot_authorz/', views.hot_authorz),
    path('hot_paperz/', views.hot_paperz),
    path('paper_recommend', views.paper_recommend),
    path('deleteAllBrowerHistory', views.deleteAllBrowerHistory),
    path('related_paper', views.related_paper),
    path('refer_string/', views.refer_string),
    path('guozong/', views.guozong),
    path('topic_orgs/', views.topic_orgs)
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Example #7
0
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.template.context_processors import static
from django.urls import path, re_path, include
from blog.views import (blog_post_create_view)
from django.conf import settings
from searches.views import search_view
from .views import home_page, about_page, contact_page, example_page
urlpatterns = [
    path('', home_page),
    path('blog-new/', blog_post_create_view),
    path('blog/', include('blog.urls')),
    path('search/', search_view),

    # path('blog/', blog_post_detail_page),
    # re_path(r'^blog/(?P<slug>\w+)/$', blog_post_detail_page),
    re_path('^pages?/$', about_page),
    re_path('page/', about_page),
    re_path('^about/$', about_page),
    path('contact/', contact_page),
    path('example/', example_page),
    path('admin/', admin.site.urls),
]

if settings.DEBUG:
    from django.conf.urls.static import static
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)
    # urlpatterns += urlpatterns+=static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Example #8
0
"""foodscan URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.template.context_processors import static
from django.urls import path, include

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
                  path('admin/', admin.site.urls),
                  path('', include('foodshow.urls'))] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Example #9
0
from django.conf.urls import url
from django.contrib import admin
from django.template.context_processors import static

from django.conf import settings
from django.conf.urls.static import static
from care import views

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$', views.IndexView.as_view(), name='homepage'),

    url(r'^about/$', views.AboutView.as_view(), name='catalogue'),
    url(r'^cooperation/$', views.CooperationView.as_view(), name='cooperation'),
    url(r'^brands/$', views.BrandsView.as_view(), name='brands'),
    url(r'^certificates/$', views.CertificateView.as_view(), name='certificates'),
    url(r'^articles/$', views.ArticleView.as_view(), name='article'),


    url(r'^catalogue/$', views.CatalogueView.as_view(), name='catalogue'),
    url(r'^product/$', views.ProductView.as_view(), name='product'),

    url(r'^contacts/$', views.ContactView.as_view(), name='contact'),
    url(r'^map/$', views.MapView.as_view(), name='map'),


] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)