File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 55from django .apps import AppConfig
66from django .db .models .signals import post_migrate
77from django .utils .translation import gettext_lazy as _
8+ from django .conf import settings
89from django .core .exceptions import ObjectDoesNotExist
910
1011import json
1112
13+ SITE_ID = getattr (settings , "SITE_ID" , 1 )
14+ INSTANCE = os .getenv ("POD_INSTANCE" , "pod" )
15+ PORT = os .getenv ("POD_PORT" , 8000 )
16+
17+ def init_site (sender , ** kwargs ):
18+ from django .contrib .sites .models import Site
19+
20+ domain = f"http://{ INSTANCE } .localhost:{ PORT } "
21+ Site .objects .update_or_create (
22+ id = settings .SITE_ID ,
23+ defaults = {
24+ "domain" : domain ,
25+ "name" : domain ,
26+ }
27+ )
28+
1229
1330def create_missing_pages (sender , ** kwargs ) -> None :
1431 """Create missing flat pages from json fixtures."""
@@ -160,3 +177,4 @@ def ready(self):
160177 post_migrate .connect (create_missing_conf , sender = self )
161178 post_migrate .connect (create_missing_pages , sender = self )
162179 post_migrate .connect (create_first_block , sender = self )
180+ post_migrate .connect (init_site , sender = self )
Original file line number Diff line number Diff line change 11[
2- {
3- "model" : " sites.site" ,
4- "pk" : 1 ,
5- "fields" : {
6- "domain" : " pod.localhost:8000" ,
7- "name" : " pod.localhost:8000"
8- }
9- },
102 {
113 "pk" : 1 ,
124 "model" : " main.configuration" ,
You can’t perform that action at this time.
0 commit comments