diff --git a/.github/workflows/django.yml b/.github/workflows/django.yml index 350a72a7..7a096154 100644 --- a/.github/workflows/django.yml +++ b/.github/workflows/django.yml @@ -13,7 +13,7 @@ jobs: strategy: max-parallel: 4 matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [ "3.10", "3.11", "3.12" ] steps: - uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index b4fa2e5c..476db191 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ *.pyo build/ dist/ -helloworld.db +*.db +*.sqlite3 local_settings.py diff --git a/Dockerfile b/Dockerfile index 68466011..ae52e075 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use an official Python runtime as a parent image -FROM python:3.6 +FROM python:3.11 # Set the working directory to /app WORKDIR /app @@ -7,14 +7,12 @@ WORKDIR /app # Copy the current directory contents into the container at /app COPY . /app -CMD ["apt","install","python3-dev","python3-pip","python3-virtualenv","sqlitebrowser"] -# Install any needed packages specified in requirements.txt -RUN pip install -r requirements.txt +# Install necessary packages and any needed packages specified in requirements.txt +RUN apt-get update && apt-get install -y python3-dev python3-pip && pip install -r requirements.txt # Make port 8000 available to the world outside this container EXPOSE 8000 -CMD ["python3","manage.py","migrate"] -# Run app.py when the container launches -CMD ["python3", "manage.py","runserver","0.0.0.0:8000"] +# Run migrations and then start the server +CMD ["sh", "-c", "python3 manage.py migrate && python3 manage.py runserver 0.0.0.0:8000"] diff --git a/README.rst b/README.rst index bb654d8f..4099c6bf 100644 --- a/README.rst +++ b/README.rst @@ -14,22 +14,28 @@ the following command: :: - $ sudo apt update + $ sudo apt update && sudo apt upgrade Install necessary minimum dependencies, with the following command: :: - $ sudo apt install python3-dev python3-pip python3-virtualenv sqlitebrowser + $ sudo apt install python3-dev python3-pip python3-virtualenv For run this example need to install Django framework executing the follow command: :: - $ sudo pip install -r requirements.txt + $ sudo pip3 install -r requirements.txt + +And later to test the Django Installation is done with the following command: + +:: + + $ python -m django --version + 5.1.6 -And later followed by: :: @@ -40,9 +46,8 @@ At which point you should see: :: Operations to perform: - Apply all migrations: admin, auth, contenttypes, sessions, sites + Apply all migrations: admin, auth, contenttypes, sessions Running migrations: - Applying contenttypes.0001_initial... OK Applying auth.0001_initial... OK Applying admin.0001_initial... OK @@ -57,9 +62,10 @@ At which point you should see: Applying auth.0007_alter_validators_add_error_messages... OK Applying auth.0008_alter_user_username_max_length... OK Applying auth.0009_alter_user_last_name_max_length... OK + Applying auth.0010_alter_group_name_max_length... OK + Applying auth.0011_update_proxy_permissions... OK + Applying auth.0012_alter_user_first_name_max_length... OK Applying sessions.0001_initial... OK - Applying sites.0001_initial... OK - Applying sites.0002_alter_domain_unique... OK For use the Django Admin Interface, it's needed to create a superuser @@ -108,14 +114,26 @@ the *Django Admin Interface* like this: Building with docker ==================== +Building image with the following command: + :: $ docker build --tag=helloworld . + +Running the container with the following command: + :: $ docker run -p 4000:8000 helloworld + +Requesting the URL http://localhost:4000 with the following command: + :: - $ curl localhost:4000 \ No newline at end of file + $ curl localhost:4000 + + +Also you can request the URL http://localhost:4000 in your web browser +you can see the hello world example. diff --git a/docs/django_admin_interface_running.png b/docs/django_admin_interface_running.png index 3443c45c..6a1303b8 100644 Binary files a/docs/django_admin_interface_running.png and b/docs/django_admin_interface_running.png differ diff --git a/docs/django_helloword.png b/docs/django_helloword.png index 82cadaa4..f4802e70 100644 Binary files a/docs/django_helloword.png and b/docs/django_helloword.png differ diff --git a/helloworld/asgi.py b/helloworld/asgi.py new file mode 100644 index 00000000..3009036d --- /dev/null +++ b/helloworld/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for helloworld project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'helloworld.settings') + +application = get_asgi_application() diff --git a/helloworld/settings.py b/helloworld/settings.py index 2bd282d8..8719a1a4 100644 --- a/helloworld/settings.py +++ b/helloworld/settings.py @@ -1,26 +1,26 @@ """ Django settings for helloworld project. -Generated by 'django-admin startproject' using Django 2.2.3. +Generated by 'django-admin startproject' using Django 5.1.6. For more information on this file, see -https://docs.djangoproject.com/en/2.2/topics/settings/ +https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.2/ref/settings/ +https://docs.djangoproject.com/en/5.1/ref/settings/ """ -import os +from pathlib import Path -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'matxp6k!wbkmdlk)97)ew2qr%&9nr=n#v_-+v#yel4^r&czf7q' +SECRET_KEY = 'django-insecure-sokpy*q9_=6j-9mrh_l)*k+&im(xfbxz_8=&u536n@9s)9&*gv' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -72,18 +72,18 @@ # Database -# https://docs.djangoproject.com/en/2.2/ref/settings/#databases +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'helloworld.db'), + 'NAME': BASE_DIR / 'helloworld.sqlite3', } } # Password validation -# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { @@ -102,7 +102,7 @@ # Internationalization -# https://docs.djangoproject.com/en/2.2/topics/i18n/ +# https://docs.djangoproject.com/en/5.1/topics/i18n/ LANGUAGE_CODE = 'en-us' @@ -112,14 +112,19 @@ # to load the internationalization machinery. USE_I18N = True -# If you set this to False, Django will not format dates, numbers and -# calendars according to the current locale -USE_L10N = True - +# If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.2/howto/static-files/ +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = 'static/' +STATICFILES_DIRS = [ + BASE_DIR / "static", +] + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field -STATIC_URL = '/static/' +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/helloworld/urls.py b/helloworld/urls.py index 9c564a78..8bf7d4fa 100644 --- a/helloworld/urls.py +++ b/helloworld/urls.py @@ -1,7 +1,8 @@ -"""helloworld URL Configuration +""" +URL configuration for helloworld project. The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/2.2/topics/http/urls/ + https://docs.djangoproject.com/en/5.1/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views diff --git a/helloworld/wsgi.py b/helloworld/wsgi.py index a7f29a9c..553cf3b2 100644 --- a/helloworld/wsgi.py +++ b/helloworld/wsgi.py @@ -4,7 +4,7 @@ It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see -https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/ +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ """ import os diff --git a/manage.py b/manage.py index 85118c4f..46e0ffbe 100644 --- a/manage.py +++ b/manage.py @@ -5,6 +5,7 @@ def main(): + """Run administrative tasks.""" os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'helloworld.settings') try: from django.core.management import execute_from_command_line diff --git a/requirements.txt b/requirements.txt index aaafdccc..5bbaebb0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ # requirements.txt file -Django==4.2.18 +Django==5.1.6 diff --git a/setup.py b/setup.py index 8a9c366d..84f86720 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ # Indicate supported versions, Python 2, Python 3 or both. "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.11", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Software Development", @@ -30,7 +30,7 @@ def read(fname): setup( name="django-helloworld", - version="0.1", + version="0.2", description="A Django 'Hello World' program example", long_description=read('README.rst'), classifiers=CLASSIFIERS, @@ -42,7 +42,7 @@ def read(fname): url="https://github.com/django-ve/django-helloworld", license="GPL", platforms="OS Independent", - install_requires=["Django==4.2.18"], + install_requires=["Django==5.1.6"], packages=find_packages(exclude=EXCLUDE_FROM_PACKAGES), include_package_data=True, zip_safe=False, diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 00000000..659ee2ae Binary files /dev/null and b/static/favicon.ico differ