diff --git a/author/migrations/0001_initial.py b/author/migrations/0001_initial.py new file mode 100644 index 0000000..fb71527 --- /dev/null +++ b/author/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 4.1 on 2024-11-23 19:59 + +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()), + ], + ), + ] diff --git a/author/models.py b/author/models.py index 4b1ae90..85ad6b6 100644 --- a/author/models.py +++ b/author/models.py @@ -7,3 +7,11 @@ class Author(models.Model): pseudonym = models.CharField(max_length=64, null=True, blank=True) age = models.IntegerField() retired = models.BooleanField() + + def get_full_name(self) -> str: + return f"{self.first_name} {self.last_name}" + + def __str__(self) -> str: + if self.pseudonym: + return f"{self.get_full_name()} ({self.pseudonym})" + return self.get_full_name() diff --git a/author/urls.py b/author/urls.py index fa856a3..d19e262 100644 --- a/author/urls.py +++ b/author/urls.py @@ -1,3 +1,3 @@ -# Create your urls here +app_name = "author" urlpatterns = [] diff --git a/author_service/settings.py b/author_service/settings.py index 8d8a42c..dc61639 100644 --- a/author_service/settings.py +++ b/author_service/settings.py @@ -113,7 +113,7 @@ LANGUAGE_CODE = "en-us" -TIME_ZONE = "UTC" +TIME_ZONE = "Europe/Kiev" USE_I18N = True diff --git a/author_service/urls.py b/author_service/urls.py index 313c351..842c50f 100644 --- a/author_service/urls.py +++ b/author_service/urls.py @@ -14,9 +14,9 @@ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path, include +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), - path("api/", include("author.urls", namespace="author")), + path("api/v1/", include("author.urls", namespace="author")), ]