diff --git a/gettingstarted/settings.py b/gettingstarted/settings.py index a4d5cf55b..b820871ce 100644 --- a/gettingstarted/settings.py +++ b/gettingstarted/settings.py @@ -1,4 +1,4 @@ -""" +F""" Django settings for gettingstarted project. Generated by 'django-admin startproject' using Django 6.0. @@ -44,7 +44,7 @@ # Debug mode will be automatically enabled when the project is run via `heroku local` (which # loads the environment variables set in the `.env` file, where `ENVIRONMENT=development`). # SECURITY WARNING: Don't run with debug turned on in production! -DEBUG = os.environ.get("ENVIRONMENT") == "development" +DEBUG = True # The `DYNO` env var is set on Heroku CI, but it's not a real Heroku app, so we have to # also explicitly exclude CI: @@ -56,7 +56,7 @@ # validation of the Host header in the incoming HTTP request. On other platforms you may need to # list the expected hostnames explicitly in production to prevent HTTP Host header attacks. See: # https://docs.djangoproject.com/en/6.0/ref/settings/#std-setting-ALLOWED_HOSTS - ALLOWED_HOSTS = ["*"] + ALLOWED_HOSTS = ['python-getting-started-lab1-lk4l.onrender.com', '127.0.0.1'] # Redirect all non-HTTPS requests to HTTPS. This requires that: # 1. Your app has a TLS/SSL certificate, which all `*.herokuapp.com` domains do by default. @@ -70,7 +70,7 @@ # https://docs.djangoproject.com/en/6.0/ref/middleware/#http-strict-transport-security SECURE_SSL_REDIRECT = True else: - ALLOWED_HOSTS = [".localhost", "127.0.0.1", "[::1]", "0.0.0.0", "[::]"] + ALLOWED_HOSTS = ['python-getting-started-lab1-lk4l.onrender.com','127.0.0.1'] # Application definition @@ -141,10 +141,9 @@ # https://github.com/jazzband/dj-database-url DATABASES = { "default": dj_database_url.config( - env="DATABASE_URL", + default=os.environ.get("DATABASE_URL", "sqlite:///db.sqlite3"), conn_max_age=600, conn_health_checks=True, - ssl_require=True, ), } else: @@ -208,7 +207,7 @@ WHITENOISE_KEEP_ONLY_HASHED_FILES = True # Customise the default logging config, since by default full Django logs are only emitted when -# `DEBUG=True` (which otherwise makes diagnosing errors much harder in production): +# DEBUG=True (which otherwise makes diagnosing errors much harder in production): # https://docs.djangoproject.com/en/6.0/ref/logging/#default-logging-configuration # For more advanced logging you may want to try: https://django-structlog.readthedocs.io LOGGING = { diff --git a/hello/migrations/0002_visit.py b/hello/migrations/0002_visit.py new file mode 100644 index 000000000..1d85f64b8 --- /dev/null +++ b/hello/migrations/0002_visit.py @@ -0,0 +1,20 @@ +# Generated by Django 6.0 on 2025-12-18 16:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hello', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Visit', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('created_at', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/hello/models.py b/hello/models.py index 974d64f7e..417367851 100644 --- a/hello/models.py +++ b/hello/models.py @@ -1,7 +1,8 @@ from django.db import models -# Create your models here. - class Greeting(models.Model): when = models.DateTimeField("date created", auto_now_add=True) + +class Visit(models.Model): + created_at = models.DateTimeField(auto_now_add=True) \ No newline at end of file diff --git a/hello/templates/index.html b/hello/templates/index.html index b4f60e59b..cdbd23940 100644 --- a/hello/templates/index.html +++ b/hello/templates/index.html @@ -8,7 +8,8 @@ -

Getting Started with Python on Heroku

+

Getting Started with Python on Heroku z UKEN

+

Liczba odwiedzin tej strony zapisanych w bazie: {{ visits }}

This is a sample Python application deployed to Heroku. It's a reasonably simple app - but a good foundation for understanding how to get the most out of the Heroku platform.

Getting Started on Heroku with Python Getting Started on Heroku Fir with Python @@ -28,6 +29,7 @@

Getting Started with Python on Heroku

How this sample app works