diff --git a/Caddyfile.dev b/Caddyfile.dev index 8d9c458..488aff7 100644 --- a/Caddyfile.dev +++ b/Caddyfile.dev @@ -1,4 +1,4 @@ -http://here.project.localhost { +http://project.localhost { root * /usr/src/app/ encode gzip zstd diff --git a/Caddyfile.pro b/Caddyfile.pro index 5122434..3ea662e 100644 --- a/Caddyfile.pro +++ b/Caddyfile.pro @@ -1,4 +1,4 @@ -https://here.project +https://project.com root * /usr/src/app/ diff --git a/Dockerfiles/django/Dockerfile b/Dockerfiles/django/Dockerfile index d79b72e..0a5ff5c 100644 --- a/Dockerfiles/django/Dockerfile +++ b/Dockerfiles/django/Dockerfile @@ -19,7 +19,6 @@ RUN apt install -y build-essential python3-dev libpq-dev python3-pip gettext # install dependencies RUN pip3 install --upgrade pip -# install basic dependencies COPY ./requirements.txt . RUN pip3 install -r requirements.txt diff --git a/Makefile b/Makefile index befa457..76b26f5 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ run.loaddata: ## Load initial data # Remove database docker-compose exec -T django bash -c "python3 manage.py flush --noinput" # Remove media - sudo rm -rf media/categories/* + rm -rf media # Migrate docker-compose exec -T django bash -c "python3 manage.py migrate" diff --git a/README.md b/README.md index e40453a..d6e599a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ make run.server Now open: -`http://here.project.localhost` +`http://project.localhost` ## Gulp @@ -68,15 +68,15 @@ make run.loaddata.test ## Other domains -- Caddy: `http://here.project.localhost`. -- Gulp: `http://here.project.localhost:3000`. -- Django: `http://here.project.localhost:8000`. -- Mailhog: `http://here.project.localhost:8025`. +- Caddy: `http://project.localhost`. +- Gulp: `http://project.localhost:3000`. +- Django: `http://project.localhost:8000`. +- Mailhog: `http://project.localhost:8025`. ### Bash Django ``` shell -docker exec -it here.project-django bash +docker exec -it project-django bash ``` # Run production @@ -85,15 +85,15 @@ docker exec -it here.project-django bash docker-compose -f docker-compose.pro.yaml up ``` -Open `https://template.io`. +Open `https://proyect.com`. # Enviroment (.env) ```text PROJECT_NAME=here.project # Domain -DOMAIN=here.project.localhost -DOMAIN_URL=http://here.project.localhost +DOMAIN=project.localhost +DOMAIN_URL=http://project.localhost # Database DB_NAME=project_db @@ -114,15 +114,12 @@ CADDY_PORT_ONE=80 CADDY_PORT_TWO=443 # Email -DEFAULT_FROM_EMAIL=no-reply@here.project.localhost -EMAIL_CONTACT=info@here.project.localhost +DEFAULT_FROM_EMAIL=no-reply@project.localhost +EMAIL_CONTACT=info@project.localhost EMAIL_HOST=mailhog EMAIL_USER= EMAIL_PASSWORD= EMAIL_PORT=1025 EMAIL_USE_TLS=False EMAIL_USE_SSL=False - -# Mailhog -MAILHOG_PORT=8025 ``` \ No newline at end of file diff --git a/test/__ini__.py b/apps/website/__init__.py similarity index 100% rename from test/__ini__.py rename to apps/website/__init__.py diff --git a/apps/website/admin.py b/apps/website/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/apps/website/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/apps/website/apps.py b/apps/website/apps.py new file mode 100644 index 0000000..f1d93d1 --- /dev/null +++ b/apps/website/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WebsiteConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "app.website" diff --git a/apps/website/migrations/__init__.py b/apps/website/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apps/website/models.py b/apps/website/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/apps/website/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/apps/website/templates/home.html b/apps/website/templates/home.html new file mode 100644 index 0000000..15f747a --- /dev/null +++ b/apps/website/templates/home.html @@ -0,0 +1 @@ +

Hi

\ No newline at end of file diff --git a/apps/website/views.py b/apps/website/views.py new file mode 100644 index 0000000..7061bb6 --- /dev/null +++ b/apps/website/views.py @@ -0,0 +1,5 @@ +from django.shortcuts import render + +# Create your views here. +def home(request): + return render(request, "home.html") diff --git a/core/asgi.py b/core/asgi.py index 04e6d00..4222035 100644 --- a/core/asgi.py +++ b/core/asgi.py @@ -11,6 +11,6 @@ import os from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "core.settings") application = get_asgi_application() diff --git a/core/settings.py b/core/settings.py index a747e7a..9e19490 100644 --- a/core/settings.py +++ b/core/settings.py @@ -36,39 +36,40 @@ if not os.environ.get("ALLOWED_HOSTS") == None: # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'django_extensions', - 'rest_framework', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "django_extensions", + "rest_framework", + "apps.website", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'core.urls' +ROOT_URLCONF = "core.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, "app", "templates")], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [os.path.join(BASE_DIR, "app", "templates")], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", ], }, }, @@ -79,7 +80,9 @@ TEMPLATES = [ # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { - "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')}") + "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 @@ -87,16 +90,16 @@ DATABASES = { AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] @@ -104,9 +107,9 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/3.2/topics/i18n/ -LANGUAGE_CODE = 'es-es' +LANGUAGE_CODE = "es-es" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -146,12 +149,10 @@ CHANNEL_LAYERS = { } - - # Default primary key field type # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" if DEBUG: CACHES = { diff --git a/core/urls.py b/core/urls.py index 3141348..38fd573 100644 --- a/core/urls.py +++ b/core/urls.py @@ -15,7 +15,8 @@ Including another URLconf """ from django.contrib import admin from django.urls import path +from app.website import views as website_views urlpatterns = [ - path('admin/', admin.site.urls), + path("admin/", admin.site.urls), ] diff --git a/docker-compose.dev.yaml b/docker-compose.dev.yaml index 66c4fe9..74d2dfe 100644 --- a/docker-compose.dev.yaml +++ b/docker-compose.dev.yaml @@ -78,5 +78,3 @@ services: restart: "no" expose: - 1025 - ports: - - ${MAILHOG_PORT}:8025 diff --git a/tests/__ini__.py b/tests/__ini__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/test_start.py b/tests/test_start.py similarity index 71% rename from test/test_start.py rename to tests/test_start.py index 6c9f592..2ea353d 100644 --- a/test/test_start.py +++ b/tests/test_start.py @@ -1,4 +1,3 @@ - def test_hello_world(): assert "hello_world" == "hello_world" - assert "foo" != "bar" \ No newline at end of file + assert "foo" != "bar"