Skip to content

Commit 67e4100

Browse files
authored
Merge pull request #32 from django-ve/2025_upgrades
Upgraded to Django 5.1.6 version
2 parents 8ec45c7 + 25b970c commit 67e4100

File tree

14 files changed

+83
-43
lines changed

14 files changed

+83
-43
lines changed

.github/workflows/django.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
max-parallel: 4
1515
matrix:
16-
python-version: [3.7, 3.8, 3.9]
16+
python-version: [ "3.10", "3.11", "3.12" ]
1717

1818
steps:
1919
- uses: actions/checkout@v3

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
*.pyo
88
build/
99
dist/
10-
helloworld.db
10+
*.db
11+
*.sqlite3
1112
local_settings.py

Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# Use an official Python runtime as a parent image
2-
FROM python:3.6
2+
FROM python:3.11
33

44
# Set the working directory to /app
55
WORKDIR /app
66

77
# Copy the current directory contents into the container at /app
88
COPY . /app
99

10-
CMD ["apt","install","python3-dev","python3-pip","python3-virtualenv","sqlitebrowser"]
11-
# Install any needed packages specified in requirements.txt
12-
RUN pip install -r requirements.txt
10+
# Install necessary packages and any needed packages specified in requirements.txt
11+
RUN apt-get update && apt-get install -y python3-dev python3-pip && pip install -r requirements.txt
1312

1413
# Make port 8000 available to the world outside this container
1514
EXPOSE 8000
1615

17-
CMD ["python3","manage.py","migrate"]
18-
# Run app.py when the container launches
19-
CMD ["python3", "manage.py","runserver","0.0.0.0:8000"]
16+
# Run migrations and then start the server
17+
CMD ["sh", "-c", "python3 manage.py migrate && python3 manage.py runserver 0.0.0.0:8000"]
2018

README.rst

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,28 @@ the following command:
1414

1515
::
1616

17-
$ sudo apt update
17+
$ sudo apt update && sudo apt upgrade
1818

1919
Install necessary minimum dependencies, with the following command:
2020

2121
::
2222

23-
$ sudo apt install python3-dev python3-pip python3-virtualenv sqlitebrowser
23+
$ sudo apt install python3-dev python3-pip python3-virtualenv
2424

2525
For run this example need to install Django framework
2626
executing the follow command:
2727

2828
::
2929

30-
$ sudo pip install -r requirements.txt
30+
$ sudo pip3 install -r requirements.txt
31+
32+
And later to test the Django Installation is done with the following command:
33+
34+
::
35+
36+
$ python -m django --version
37+
5.1.6
3138

32-
And later followed by:
3339

3440
::
3541

@@ -40,9 +46,8 @@ At which point you should see:
4046
::
4147

4248
Operations to perform:
43-
Apply all migrations: admin, auth, contenttypes, sessions, sites
49+
Apply all migrations: admin, auth, contenttypes, sessions
4450
Running migrations:
45-
4651
Applying contenttypes.0001_initial... OK
4752
Applying auth.0001_initial... OK
4853
Applying admin.0001_initial... OK
@@ -57,9 +62,10 @@ At which point you should see:
5762
Applying auth.0007_alter_validators_add_error_messages... OK
5863
Applying auth.0008_alter_user_username_max_length... OK
5964
Applying auth.0009_alter_user_last_name_max_length... OK
65+
Applying auth.0010_alter_group_name_max_length... OK
66+
Applying auth.0011_update_proxy_permissions... OK
67+
Applying auth.0012_alter_user_first_name_max_length... OK
6068
Applying sessions.0001_initial... OK
61-
Applying sites.0001_initial... OK
62-
Applying sites.0002_alter_domain_unique... OK
6369

6470

6571
For use the Django Admin Interface, it's needed to create a superuser
@@ -108,14 +114,26 @@ the *Django Admin Interface* like this:
108114
Building with docker
109115
====================
110116

117+
Building image with the following command:
118+
111119
::
112120

113121
$ docker build --tag=helloworld .
114122

123+
124+
Running the container with the following command:
125+
115126
::
116127

117128
$ docker run -p 4000:8000 helloworld
118129

130+
131+
Requesting the URL http://localhost:4000 with the following command:
132+
119133
::
120134

121-
$ curl localhost:4000
135+
$ curl localhost:4000
136+
137+
138+
Also you can request the URL http://localhost:4000 in your web browser
139+
you can see the hello world example.
3.46 KB
Loading

docs/django_helloword.png

868 Bytes
Loading

helloworld/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for helloworld project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'helloworld.settings')
15+
16+
application = get_asgi_application()

helloworld/settings.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
"""
22
Django settings for helloworld project.
33
4-
Generated by 'django-admin startproject' using Django 2.2.3.
4+
Generated by 'django-admin startproject' using Django 5.1.6.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/2.2/topics/settings/
7+
https://docs.djangoproject.com/en/5.1/topics/settings/
88
99
For the full list of settings and their values, see
10-
https://docs.djangoproject.com/en/2.2/ref/settings/
10+
https://docs.djangoproject.com/en/5.1/ref/settings/
1111
"""
1212

13-
import os
13+
from pathlib import Path
1414

15-
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
1717

1818

1919
# Quick-start development settings - unsuitable for production
20-
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
20+
# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/
2121

2222
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = 'matxp6k!wbkmdlk)97)ew2qr%&9nr=n#v_-+v#yel4^r&czf7q'
23+
SECRET_KEY = 'django-insecure-sokpy*q9_=6j-9mrh_l)*k+&im(xfbxz_8=&u536n@9s)9&*gv'
2424

2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
@@ -72,18 +72,18 @@
7272

7373

7474
# Database
75-
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
75+
# https://docs.djangoproject.com/en/5.1/ref/settings/#databases
7676

7777
DATABASES = {
7878
'default': {
7979
'ENGINE': 'django.db.backends.sqlite3',
80-
'NAME': os.path.join(BASE_DIR, 'helloworld.db'),
80+
'NAME': BASE_DIR / 'helloworld.sqlite3',
8181
}
8282
}
8383

8484

8585
# Password validation
86-
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
86+
# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators
8787

8888
AUTH_PASSWORD_VALIDATORS = [
8989
{
@@ -102,7 +102,7 @@
102102

103103

104104
# Internationalization
105-
# https://docs.djangoproject.com/en/2.2/topics/i18n/
105+
# https://docs.djangoproject.com/en/5.1/topics/i18n/
106106

107107
LANGUAGE_CODE = 'en-us'
108108

@@ -112,14 +112,19 @@
112112
# to load the internationalization machinery.
113113
USE_I18N = True
114114

115-
# If you set this to False, Django will not format dates, numbers and
116-
# calendars according to the current locale
117-
USE_L10N = True
118-
115+
# If you set this to False, Django will not use timezone-aware datetimes.
119116
USE_TZ = True
120117

121118

122119
# Static files (CSS, JavaScript, Images)
123-
# https://docs.djangoproject.com/en/2.2/howto/static-files/
120+
# https://docs.djangoproject.com/en/5.1/howto/static-files/
121+
122+
STATIC_URL = 'static/'
123+
STATICFILES_DIRS = [
124+
BASE_DIR / "static",
125+
]
126+
127+
# Default primary key field type
128+
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field
124129

125-
STATIC_URL = '/static/'
130+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

helloworld/urls.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
"""helloworld URL Configuration
1+
"""
2+
URL configuration for helloworld project.
23
34
The `urlpatterns` list routes URLs to views. For more information please see:
4-
https://docs.djangoproject.com/en/2.2/topics/http/urls/
5+
https://docs.djangoproject.com/en/5.1/topics/http/urls/
56
Examples:
67
Function views
78
1. Add an import: from my_app import views

helloworld/wsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
It exposes the WSGI callable as a module-level variable named ``application``.
55
66
For more information on this file, see
7-
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
7+
https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/
88
"""
99

1010
import os

0 commit comments

Comments
 (0)