Skip to content

Commit

Permalink
ready solution
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-puhach committed Nov 23, 2024
1 parent 7155dc0 commit ec3eeaa
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 15 deletions.
32 changes: 32 additions & 0 deletions author/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 4.1 on 2024-11-23 13:52

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="Author",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("first_name", models.CharField(max_length=64)),
("last_name", models.CharField(max_length=64)),
("pseudonym", models.CharField(blank=True, max_length=64, null=True)),
("age", models.IntegerField()),
("retired", models.BooleanField()),
],
),
]
7 changes: 5 additions & 2 deletions author/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from rest_framework import serializers

from author.models import Author


class AuthorSerializer(serializers.ModelSerializer):
# write your code here
pass
class Meta:
model = Author
fields = "__all__"
15 changes: 13 additions & 2 deletions author/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# Create your urls here
from django.urls import path, include
from rest_framework import routers

urlpatterns = []

from author.views import AuthorViewSet

router = routers.DefaultRouter()
router.register("authors", AuthorViewSet, basename="manage")

urlpatterns = [
path("", include(router.urls)),
]

app_name = "author"
7 changes: 5 additions & 2 deletions author/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from rest_framework import viewsets

from author.models import Author
from author.serializers import AuthorSerializer


class AuthorViewSet(viewsets.ModelViewSet):
# write your code here
pass
queryset = Author.objects.all()
serializer_class = AuthorSerializer
14 changes: 5 additions & 9 deletions author_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = (
"django-insecure-4l*aqy-h!k0a$)68da!_zw#x8)jo0r&!5aqd9gcv9z3zr)h)*="
)
SECRET_KEY = "django-insecure-4l*aqy-h!k0a$)68da!_zw#x8)jo0r&!5aqd9gcv9z3zr)h)*="

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand All @@ -41,6 +39,7 @@
"django.contrib.staticfiles",
"rest_framework",
"author",
"django_extensions",
]

MIDDLEWARE = [
Expand Down Expand Up @@ -94,16 +93,13 @@
"UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation."
"MinimumLengthValidator",
"NAME": "django.contrib.auth.password_validation." "MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation."
"CommonPasswordValidator",
"NAME": "django.contrib.auth.password_validation." "CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation."
"NumericPasswordValidator",
"NAME": "django.contrib.auth.password_validation." "NumericPasswordValidator",
},
]

Expand Down
1 change: 1 addition & 0 deletions author_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include

Expand Down

0 comments on commit ec3eeaa

Please sign in to comment.