Skip to content

Commit

Permalink
Initialize author app, modify settings, and update URLs
Browse files Browse the repository at this point in the history
- Added initial author migration.
- Implemented get_full_name and __str__ Author model methods.
- Updated timezone in project settings.
- Added app_name in author/urls.
  • Loading branch information
vladyslav-tmf committed Nov 23, 2024
1 parent 7155dc0 commit aefa9f0
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
25 changes: 25 additions & 0 deletions author/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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()),
],
),
]
8 changes: 8 additions & 0 deletions author/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion author/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Create your urls here
app_name = "author"

urlpatterns = []
2 changes: 1 addition & 1 deletion author_service/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"
TIME_ZONE = "Europe/Kiev"

USE_I18N = True

Expand Down
4 changes: 2 additions & 2 deletions author_service/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
]

0 comments on commit aefa9f0

Please sign in to comment.