diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e5c8df4..4113440 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,14 +4,7 @@
-
-
-
-
-
-
-
-
+
@@ -100,7 +93,7 @@
1719511805110
-
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
index af09d9b..7d20a18 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,6 +3,7 @@
"python.analysis.indexing": true,
"python.analysis.packageIndexDepths":[["rest_framework", 5, true]],
"cSpell.words": [
+ "authtoken",
"viewsets"
]
}
\ No newline at end of file
diff --git a/db.sqlite3 b/db.sqlite3
index 81f1ebb..9015e35 100644
Binary files a/db.sqlite3 and b/db.sqlite3 differ
diff --git a/tJango/__pycache__/settings.cpython-312.pyc b/tJango/__pycache__/settings.cpython-312.pyc
index ae4f952..bc81840 100644
Binary files a/tJango/__pycache__/settings.cpython-312.pyc and b/tJango/__pycache__/settings.cpython-312.pyc differ
diff --git a/tJango/settings.py b/tJango/settings.py
index bfe3921..b8b1816 100644
--- a/tJango/settings.py
+++ b/tJango/settings.py
@@ -38,13 +38,14 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
+ 'rest_framework.authtoken',
'hello',
'user',
]
REST_FRAMEWORK = {
- 'DEFAULT_PERMISSION_CLASSES': [
- 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
+ 'DEFAULT_AUTHENTICATION_CLASSES': [
+ 'rest_framework.authentication.TokenAuthentication',
]
}
diff --git a/user/migrations/0002_alter_user_username.py b/user/migrations/0002_alter_user_username.py
new file mode 100644
index 0000000..686b2fa
--- /dev/null
+++ b/user/migrations/0002_alter_user_username.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.6 on 2024-06-29 23:13
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('user', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='user',
+ name='username',
+ field=models.CharField(max_length=15, unique=True),
+ ),
+ ]
diff --git a/user/views.py b/user/views.py
index 76276fe..7c5caec 100644
--- a/user/views.py
+++ b/user/views.py
@@ -1,5 +1,6 @@
from django.shortcuts import render
from rest_framework import viewsets
+from rest_framework.permissions import IsAuthenticatedOrReadOnly
from rest_framework.decorators import action
from .models import User
from .serializers import UserSerializer
@@ -10,7 +11,8 @@ from .serializers import UserSerializer
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
+ permission_classes = [IsAuthenticatedOrReadOnly]
- @action(detail=True, methods=['get'])
+ @action(detail=False, methods=['get'])
def print_this(self, request, pk=None):
print(self.get_object())