new backend data structure

This commit is contained in:
Chneemann 2024-08-04 08:25:52 +02:00
parent f61ff3c93d
commit aa660a1289
15 changed files with 9 additions and 52 deletions

3
backend/.gitignore vendored
View file

@ -143,4 +143,5 @@ GitHub.sublime-settings
# Migrations # # Migrations #
**/migrations/** **/migrations/**
!**/migrations !**/migrations
!**/migrations/__init__.py !**/migrations/__init__.py
videoflix/user/migrations

View file

@ -20,7 +20,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-l88ot$w3&q2v439@j_5ps()@1*fa&ho1o=eiig9##0!#3mz9nr' SECRET_KEY = 'django-insecure-0uaid_f*y1j7ukfk5*im@axnjp#scxb51w#8j*^18axqc#o#v('
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
@ -30,11 +30,6 @@ ALLOWED_HOSTS = []
# Application definition # Application definition
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}
INSTALLED_APPS = [ INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.auth', 'django.contrib.auth',
@ -42,8 +37,6 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'rest_framework',
'users',
] ]
MIDDLEWARE = [ MIDDLEWARE = [

View file

@ -15,16 +15,8 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import path
from rest_framework import routers
from users import views
router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet)
router.register(r'groups', views.GroupViewSet)
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', include(router.urls)),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
] ]

View file

@ -1,6 +1,6 @@
from django.apps import AppConfig from django.apps import AppConfig
class UsersConfig(AppConfig): class UserConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField' default_auto_field = 'django.db.models.BigAutoField'
name = 'users' name = 'user'

View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View file

@ -1,12 +0,0 @@
from django.contrib.auth.models import User, Group
from rest_framework import serializers
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ['url', 'id', 'username', 'email']
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ['url', 'name']

View file

@ -1,20 +0,0 @@
from django.shortcuts import render
from django.contrib.auth.models import Group, User
from rest_framework import permissions, viewsets
from users.serializer import GroupSerializer, UserSerializer
class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = User.objects.all().order_by('id')
serializer_class = UserSerializer
# permission_classes = [permissions.IsAuthenticated]
class GroupViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows groups to be viewed or edited.
"""
queryset = Group.objects.all().order_by('name')
serializer_class = GroupSerializer
# permission_classes = [permissions.IsAuthenticated]