import django from .. import views if django.VERSION < (4, 0, 0): from django.conf.urls import url as handler else: from django.urls import re_path as handler urlpatterns = [ handler(r"^$", views.index), handler(r"^simple/$", views.BasicView.as_view()), ]
""" user = User(username="******") user.save() login(request, user) return HttpResponse(status=200) def shutdown(request): # Endpoint used to flush traces to the agent when doing snapshots. tracer.shutdown() return HttpResponse(status=200) urlpatterns = [ handler(r"^$", views.index), handler(r"^simple/$", views.BasicView.as_view()), handler(r"^users/$", views.UserList.as_view(), name="users-list"), handler(r"^cached-template/$", views.TemplateCachedUserList.as_view(), name="cached-template-list"), handler(r"^safe-template/$", views.SafeTemplateUserList.as_view(), name="safe-template-list"), handler(r"^cached-users/$", cache_page(60)(views.UserList.as_view()), name="cached-users-list"), handler(r"^fail-view/$", views.ForbiddenView.as_view(), name="forbidden-view"), handler(r"^authenticated/$", authenticated_view,
import django from django.http import HttpResponse if django.VERSION < (4, 0, 0): from django.conf.urls import url as handler else: from django.urls import re_path as handler def include_view(request): return HttpResponse(status=200) urlpatterns = [ handler("test/", include_view), ]
from django.conf.urls import url as handler else: from django.urls import re_path as handler class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = User fields = ("url", "username", "email", "groups") class UserViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited. """ queryset = User.objects.all().order_by("-date_joined") serializer_class = UserSerializer router = routers.DefaultRouter() router.register(r"users", UserViewSet) # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. urlpatterns = [ handler(r"^", include(router.urls)), handler(r"^api-auth/", include("rest_framework.urls", namespace="rest_framework")), ]