diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b46ea70..c6baf6e 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,20 +1,11 @@ + + - - - - - - - - - - - - - + - { - "keyToString": { - "ASKED_ADD_EXTERNAL_FILES": "true", - "RunOnceActivity.OpenDjangoStructureViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "git-widget-placeholder": "main", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable", - "vue.rearranger.settings.migration": "true" + +}]]> @@ -99,7 +94,7 @@ diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..ab27b3d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cSpell.words": [ + "viewsets" + ] +} \ No newline at end of file diff --git a/hello/__pycache__/views.cpython-312.pyc b/hello/__pycache__/views.cpython-312.pyc index e442efe..8eec5eb 100644 Binary files a/hello/__pycache__/views.cpython-312.pyc and b/hello/__pycache__/views.cpython-312.pyc differ diff --git a/tJango/__pycache__/settings.cpython-312.pyc b/tJango/__pycache__/settings.cpython-312.pyc index 95b5676..cab51b7 100644 Binary files a/tJango/__pycache__/settings.cpython-312.pyc and b/tJango/__pycache__/settings.cpython-312.pyc differ diff --git a/tJango/__pycache__/urls.cpython-312.pyc b/tJango/__pycache__/urls.cpython-312.pyc index f471974..9459729 100644 Binary files a/tJango/__pycache__/urls.cpython-312.pyc and b/tJango/__pycache__/urls.cpython-312.pyc differ diff --git a/tJango/settings.py b/tJango/settings.py index 9eb0c27..a84ce1e 100644 --- a/tJango/settings.py +++ b/tJango/settings.py @@ -37,8 +37,15 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'rest_framework', ] +REST_FRAMEWORK = { + 'DEFAULT_PERMISSION_CLASSES': [ + 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' + ] +} + MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', diff --git a/tJango/urls.py b/tJango/urls.py index 340ebd6..ef70de5 100644 --- a/tJango/urls.py +++ b/tJango/urls.py @@ -16,8 +16,24 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.contrib.auth.models import User +from rest_framework import routers, serializers, viewsets + +class UserSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = User + fields = ['url', 'username', 'email', 'is_staff'] + +class UserViewSet(viewsets.ModelViewSet): + queryset = User.objects.all() + serializer_class = UserSerializer + +router = routers.DefaultRouter() +router.register(r'users', UserViewSet) urlpatterns = [ - path("", include("hello.urls")), + path('api-auth/', include('rest_framework.urls')), + path('hello', include("hello.urls")), + path('', include(router.urls)), path('admin/', admin.site.urls), ]