File tree Expand file tree Collapse file tree 9 files changed +47
-16
lines changed
website/management/commands Expand file tree Collapse file tree 9 files changed +47
-16
lines changed Original file line number Diff line number Diff line change @@ -24,4 +24,4 @@ COPY . /code/
24
24
RUN python manage.py collectstatic --noinput
25
25
26
26
# Start server
27
- CMD python manage.py migrate && python manage.py createsuperuser && gunicorn crm_platform .wsgi:application --bind 0.0.0.0:8000
27
+ CMD python manage.py migrate && python manage.py createsuperauto && gunicorn app .wsgi:application --bind 0.0.0.0:8000
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
"""
2
- ASGI config for crm_platform project.
2
+ ASGI config for app project.
3
3
4
4
It exposes the ASGI callable as a module-level variable named ``application``.
5
5
11
11
12
12
from django .core .asgi import get_asgi_application
13
13
14
- os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'crm_platform .settings' )
14
+ os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'app .settings' )
15
15
16
16
application = get_asgi_application ()
Original file line number Diff line number Diff line change 1
1
"""
2
- Django settings for crm_platform project.
2
+ Django settings for app project.
3
3
4
4
Generated by 'django-admin startproject' using Django 5.0.4.
5
5
56
56
'whitenoise.middleware.WhiteNoiseMiddleware' ,
57
57
]
58
58
59
- ROOT_URLCONF = 'crm_platform .urls'
59
+ ROOT_URLCONF = 'app .urls'
60
60
61
61
TEMPLATES = [
62
62
{
74
74
},
75
75
]
76
76
77
- WSGI_APPLICATION = 'crm_platform .wsgi.application'
77
+ WSGI_APPLICATION = 'app .wsgi.application'
78
78
79
79
80
80
# Database
Original file line number Diff line number Diff line change 1
1
"""
2
- URL configuration for crm_platform project.
2
+ URL configuration for app project.
3
3
4
4
The `urlpatterns` list routes URLs to views. For more information please see:
5
5
https://docs.djangoproject.com/en/5.0/topics/http/urls/
Original file line number Diff line number Diff line change 1
1
"""
2
- WSGI config for crm_platform project.
2
+ WSGI config for app project.
3
3
4
4
It exposes the WSGI callable as a module-level variable named ``application``.
5
5
11
11
12
12
from django .core .wsgi import get_wsgi_application
13
13
14
- os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'crm_platform .settings' )
14
+ os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'app .settings' )
15
15
16
16
application = get_wsgi_application ()
Original file line number Diff line number Diff line change 6
6
7
7
def main ():
8
8
"""Run administrative tasks."""
9
- os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'crm_platform .settings' )
9
+ os .environ .setdefault ('DJANGO_SETTINGS_MODULE' , 'app .settings' )
10
10
try :
11
11
from django .core .management import execute_from_command_line
12
12
except ImportError as exc :
Original file line number Diff line number Diff line change
1
+ from django .core .management .base import BaseCommand
2
+ from django .contrib .auth import get_user_model
3
+ import logging
4
+
5
+ class Command (BaseCommand ):
6
+ def handle (self , * args , ** options ):
7
+ User = get_user_model ()
8
+ logger = logging .getLogger (__name__ )
9
+ if not User .objects .filter (username = 'admin' ).exists ():
10
+ User .
objects .
create_superuser (
'admin' ,
'[email protected] ' ,
'admin' )
11
+ logger .info ("Superuser 'admin' created automatically" )
12
+ else :
13
+ logger .info ("Superuser 'admin' already exists" )
Original file line number Diff line number Diff line change @@ -9,29 +9,47 @@ services:
9
9
- POSTGRES_PASSWORD=password
10
10
11
11
runmigrations :
12
- extends :
13
- file : compose.yaml
14
- service : django
15
12
restart : on-failure
13
+ build : ./app
16
14
environment :
17
- - DEBUG=False
15
+ - DB_HOST=db
16
+ - DEBUG=True
17
+ - POSTGRES_USER=django
18
+ - POSTGRES_DB=django
18
19
- POSTGRES_PASSWORD=password
20
+ volumes :
21
+ - " ./app:/code"
19
22
command : python manage.py migrate
20
23
depends_on :
21
24
- db
22
25
26
+ createsuperuser :
27
+ restart : on-failure
28
+ build : ./app
29
+ environment :
30
+ - DB_HOST=db
31
+ - DEBUG=True
32
+ - POSTGRES_USER=django
33
+ - POSTGRES_DB=django
34
+ - POSTGRES_PASSWORD=password
35
+ volumes :
36
+ - " ./app:/code"
37
+ command : python manage.py createsuperauto
38
+ depends_on :
39
+ - db
40
+
23
41
django :
24
42
extends :
25
43
file : compose.yaml
26
44
service : django
27
45
environment :
28
- - DEBUG=False
46
+ - DEBUG=True
29
47
- POSTGRES_PASSWORD=password
30
48
volumes :
31
49
- " ./app:/code"
32
50
command : python manage.py runserver 0.0.0.0:8000
33
51
depends_on :
34
- - runmigrations
52
+ - createsuperuser
35
53
36
54
volumes :
37
55
postgres_data:
You can’t perform that action at this time.
0 commit comments