update code and fix errors

update code and fix errors
This commit is contained in:
jnfire 2022-08-02 08:56:21 +02:00
parent fc650af1b7
commit ae2758a44f
18 changed files with 72 additions and 59 deletions

View File

@ -1,4 +1,4 @@
http://here.project.localhost {
http://project.localhost {
root * /usr/src/app/
encode gzip zstd

View File

@ -1,4 +1,4 @@
https://here.project
https://project.com
root * /usr/src/app/

View File

@ -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

View File

@ -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"

View File

@ -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
```

3
apps/website/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
apps/website/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class WebsiteConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "app.website"

View File

3
apps/website/models.py Normal file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@ -0,0 +1 @@
<h1>Hi</h1>

5
apps/website/views.py Normal file
View File

@ -0,0 +1,5 @@
from django.shortcuts import render
# Create your views here.
def home(request):
return render(request, "home.html")

View File

@ -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()

View File

@ -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 = {

View File

@ -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),
]

View File

@ -78,5 +78,3 @@ services:
restart: "no"
expose:
- 1025
ports:
- ${MAILHOG_PORT}:8025

0
tests/__ini__.py Normal file
View File

View File

@ -1,4 +1,3 @@
def test_hello_world():
assert "hello_world" == "hello_world"
assert "foo" != "bar"