feat: added users app
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -0,0 +1,10 @@
|
||||
from rest_framework import serializers
|
||||
|
||||
from files.models import FileUpload
|
||||
|
||||
|
||||
class FileUploadSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = FileUpload
|
||||
fields = ('file', 'id')
|
||||
read_only_fields = ('id', )
|
||||
@@ -0,0 +1,8 @@
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
from files.api.v1.views import FileUploadViewSet
|
||||
|
||||
router = DefaultRouter(trailing_slash=True)
|
||||
router.register('', FileUploadViewSet)
|
||||
|
||||
urlpatterns = router.urls
|
||||
@@ -0,0 +1,8 @@
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
from files.api.v1.serializers import FileUploadSerializer
|
||||
from files.models import FileUpload
|
||||
|
||||
|
||||
class FileUploadViewSet(ModelViewSet):
|
||||
serializer_class = FileUploadSerializer
|
||||
queryset = FileUpload.objects.all()
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class FilesConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "files"
|
||||
@@ -0,0 +1,28 @@
|
||||
# Generated by Django 5.0.3 on 2024-05-04 22:12
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="FileUpload",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("file", models.FileField(upload_to="uploads")),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class FileUpload(models.Model):
|
||||
file = models.FileField(upload_to="uploads", blank=False, null=False)
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user