fix names

fix names
This commit is contained in:
jnfire 2022-07-29 15:15:22 +02:00
parent e51406e31a
commit 128271411d
8 changed files with 79 additions and 32 deletions

View File

@ -9,9 +9,9 @@ format: ## Format style with black
black --exclude="/(postgres|venv|migrations|\.git)/" .
docker.recreate.django: ## Recreate Django image
docker-compose -f docker-compose.yaml build --no-cache --force-rm django
docker-compose -f docker-compose.yaml up --force-recreate --no-deps -d django
make run.loaddata
docker-compose -f docker-compose.dev.yaml build --no-cache --force-rm django
docker-compose -f docker-compose.dev.yaml up --force-recreate --no-deps -d django
## make run.loaddata
run.makemigrations: ## Makemigrations
docker-compose -f docker-compose.yaml exec -T django bash -c "python3 manage.py makemigrations"
@ -21,18 +21,19 @@ run.migrate: ## Migrate
run.loaddata: ## Load initial data
# Remove database
rm -rf database.sqlite
docker-compose exec -T django bash -c "python3 manage.py flush --noinput"
# Remove media
rm -rf media
sudo rm -rf media/categories/*
# Migrate
docker-compose -f docker-compose.yaml exec -T django bash -c "python3 manage.py migrate"
docker-compose exec -T django bash -c "python3 manage.py migrate"
run.loaddata.test: ## Load initial data test
make run.loaddata
# Add superuser: alias "admin" - password "admin"
docker-compose -f docker-compose.yaml exec -T django bash -c "cat data/create_superuser.py | python3 manage.py shell"
# Add more users: alias random - password "password"
docker-compose -f docker-compose.yaml exec -T django bash -c "cat data/create_users.py | python3 manage.py shell"
docker-compose -f docker-compose.dev.yaml exec -T django bash -c "cat data/create_superuser.py | python3 manage.py shell"
run.server: ## Run server
docker-compose -f docker-compose.yaml up
run.server.dev: ## Run server
docker-compose -f docker-compose.dev.yaml up
run.server.pro: ## Run server
docker-compose -f docker-compose.pro.yaml up

View File

@ -8,7 +8,7 @@ make run.server
Now open:
`http://ccstech.localhost`
`http://template.localhost`
## Gulp
@ -68,15 +68,15 @@ make run.loaddata.test
## Other domains
- Caddy: `http://ccstech.localhost`.
- Gulp: `http://ccstech.localhost:3000`.
- Django: `http://ccstech.localhost:8000`.
- Mailhog: `http://ccstech.localhost:8025`.
- Caddy: `http://template.localhost`.
- Gulp: `http://template.localhost:3000`.
- Django: `http://template.localhost:8000`.
- Mailhog: `http://template.localhost:8025`.
### Bash Django
``` shell
docker exec -it ccstech_django_1 bash
docker exec -it template-django bash
```
# Run production
@ -85,4 +85,44 @@ docker exec -it ccstech_django_1 bash
docker-compose -f docker-compose.pro.yaml up
```
Open `https://ccstech.io`.
Open `https://template.io`.
# Enviroment (.env)
```text
PROJECT_NAME=template
# Domain
DOMAIN=template.localhost
DOMAIN_URL=http://template.localhost
# Database
DB_NAME=template_db
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=postgresql
DB_PORT=5432
# Django options
DJANGO_SECRET_KEY=mysecret
# Redis
REDIS_HOST=redis
REDIS_PORT=6379
# Caddy
CADDY_PORT_ONE=80
CADDY_PORT_TWO=443
# Email
DEFAULT_FROM_EMAIL=no-reply@template.localhost
EMAIL_CONTACT=info@template.localhost
EMAIL_HOST=mailhog
EMAIL_USER=
EMAIL_PASSWORD=
EMAIL_PORT=1025
EMAIL_USE_TLS=False
EMAIL_USE_SSL=False
# Mailhog
MAILHOG_PORT=8025
```

View File

@ -1,5 +1,5 @@
"""
ASGI config for ccstech project.
ASGI config for core project.
It exposes the ASGI callable as a module-level variable named ``application``.
@ -11,6 +11,6 @@ import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ccstech.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
application = get_asgi_application()

View File

@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
import dj_database_url
from pathlib import Path
from django.db.backends.signals import connection_created
@ -78,14 +79,7 @@ TEMPLATES = [
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": os.environ.get("DB_ENGINE"),
"NAME": os.environ.get("DB_NAME"),
"USER": os.environ.get("DB_USER"),
"PASSWORD": os.environ.get("DB_PASSWORD"),
"HOST": os.environ.get("DB_HOST"),
"PORT": os.environ.get("DB_PORT"),
}
"default": dj_database_url.config(default=f"postgres://{os.environ.get('DB_USER')}:{os.environ.get('DB_PASSWORD')}@{os.environ.get('DB_HOST')}:{os.environ.get('DB_PORT')}/{os.environ.get('DB_NAME')}")
}
# Password validation

View File

@ -1,4 +1,4 @@
"""ccstech URL Configuration
"""template URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.0/topics/http/urls/
@ -15,9 +15,7 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from app.website import views as website_views
urlpatterns = [
path('', website_views.home, name='home'),
path('admin/', admin.site.urls),
]

View File

@ -75,6 +75,7 @@ services:
mailhog:
image: mailhog/mailhog:latest
container_name: ${PROJECT_NAME}-mailhog
restart: "no"
expose:
- 1025

View File

@ -6,7 +6,7 @@ import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ccstech.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:

View File

@ -1,10 +1,18 @@
# Django
django===4.0.6
django-extensions===3.2.0
dj-database-url==0.5.0
# Django REST
djangorestframework==3.13.1
django-cors-headers==3.10.0
# PostgreSQL driver
psycopg2-binary===2.9.3
# Check connection
redis==4.3.4
# Django Server
daphne===3.0.2
asgiref===3.5.2
@ -16,3 +24,8 @@ Pillow===9.2.0
# Testing
pytest==7.1.2
pytest-django==4.5.2
# Quality code
black==22.6.0
flake8==4.0.1
isort==5.10.1