Beispiel #1
0
from django.conf.urls import patterns, include, url
from polls.views import (RootResource, QuestionCollectionResource,
                         QuestionResource, ChoiceResource)


urlpatterns = patterns('',
    url(r'^$', RootResource.as_view()),
    url(r'^questions$', QuestionCollectionResource.as_view()),
    url(r'^questions/(?P<pk>[\d]+)$', QuestionResource.as_view()),
    url(r'^questions/(?P<question_pk>[\d]+)/choices/(?P<pk>[\d]+)$', ChoiceResource.as_view()),
)
Beispiel #2
0
    try:
        connections['default'].cursor()
    except ImproperlyConfigured:
        # Database is not configured (DATABASE_URL may not be set)
        database_accessible = False
    except OperationalError:
        # Database is not accessible
        database_accessible = False

    if database_accessible:
        return JsonResponse({'status': 'ok'}, content_type=content_type)

    return JsonResponse({'status': 'fail'},
                        status=503,
                        content_type=content_type)


def error_view(request):
    raise Exception('Test exception')


urlpatterns = [
    path('', RootResource.as_view()),
    path('questions', QuestionCollectionResource.as_view()),
    path('questions/<int:pk>', QuestionResource.as_view()),
    path('questions/<int:question_pk>/choices/<int:pk>',
         ChoiceResource.as_view()),
    path('healthcheck', healthcheck_view),
    path('500', error_view),
]
Beispiel #3
0
from django.conf.urls import patterns, include, url
from polls.views import RootResource, QuestionCollectionResource, QuestionResource, ChoiceResource


urlpatterns = patterns(
    "",
    url(r"^$", RootResource.as_view()),
    url(r"^questions$", QuestionCollectionResource.as_view()),
    url(r"^questions/(?P<pk>[\d]+)$", QuestionResource.as_view()),
    url(r"^questions/(?P<question_pk>[\d]+)/choices/(?P<pk>[\d]+)$", ChoiceResource.as_view()),
)