Skip to content

Commit 26a7a77

Browse files
oxonium0215oxonium0215
authored andcommitted
fix: Dockerで本番用のconfigプロジェクトからworldアプリを読み込めるように修正
1 parent 8f59faa commit 26a7a77

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

config/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
"""
1212

1313
import os
14+
import sys
1415
import environ
1516
from pathlib import Path
1617

1718
# Build paths inside the project like this: BASE_DIR / 'subdir'.
1819
BASE_DIR = Path(__file__).resolve().parent.parent
1920

21+
# Add geodjango directory to sys.path so 'world' app can be imported
22+
sys.path.insert(0, os.path.join(BASE_DIR, "geodjango"))
23+
2024
env = environ.Env()
2125
environ.Env.read_env(os.path.join(BASE_DIR, ".env"))
2226

@@ -40,6 +44,7 @@
4044
"pwa",
4145
"storages",
4246
"config",
47+
"world",
4348
]
4449

4550
MIDDLEWARE = [

config/urls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1616
"""
1717
from django.contrib import admin
18-
from django.urls import path
18+
from django.urls import path, include
19+
from world.views import map_page
1920
from . import views
2021

2122
urlpatterns = [
2223
path('admin/', admin.site.urls),
23-
path('', views.index, name='index'),
24+
path('', map_page, name='index'), # Serve map on the root page
2425
path('health/', views.health, name='health'),
26+
path('maps/', include('world.urls')),
2527
]

geodjango/world/description.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
from openai import OpenAI
44
from .models import Pin
55
from .wiki import search_first_pageid, get_extract
6-
_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
6+
_client = None
7+
if os.getenv("OPENAI_API_KEY"):
8+
_client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
79
DEFAULT_MODEL="gpt-5-mini"
810
def load_address(name: str, address: Optional[dict]) -> str:
911
text=""

0 commit comments

Comments
 (0)