City as select

This commit is contained in:
Eden Kirin
2024-05-16 21:40:28 +02:00
parent fc6b3a7fa0
commit 382e514d03
4 changed files with 85 additions and 50 deletions

View File

@ -8,6 +8,15 @@ from django.shortcuts import render
from project.main.models import Person
from project.main.views.demo_view_base import DemoViewBase
CITIES: list[str] = [
"",
"Zagreb",
"Split",
"Pula",
"Rijeka",
"Kozari bok",
]
def get_person(pk: int) -> Person:
try:
@ -46,6 +55,7 @@ class TableInlineEditRowView(DemoViewBase):
context_data.update(
{
"person": person,
"cities": CITIES,
"is_editing": action == "edit",
}
)
@ -66,12 +76,11 @@ class TableInlineEditRowView(DemoViewBase):
else:
person.save()
print(errors)
return render(
context={
"person": person,
"errors": errors,
"cities": CITIES,
"is_editing": errors is not None,
},
template_name=self.template_name,