Skip to content

Commit

Permalink
chore: update Django samples to 5.1 (Python 3.10+) (#12122)
Browse files Browse the repository at this point in the history
* update django dependencies to latest per python version

* chore: django-update, target minimum supported django

* fix: import order

* remove redundant template comment

* bump django patch version

* fix: update django versions

* fox: update config settings
  • Loading branch information
glasnt authored Aug 9, 2024
1 parent 03cb622 commit 3b1d83f
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 73 deletions.
11 changes: 8 additions & 3 deletions appengine/flexible/django_cloudsql/mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

Expand All @@ -168,8 +167,14 @@
# Define static storage via django-storages[google]
GS_BUCKET_NAME = env("GS_BUCKET_NAME")
STATIC_URL = "/static/"
DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
STATICFILES_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
STORAGES = {
"default": {
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
},
"staticfiles": {
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
},
}
GS_DEFAULT_ACL = "publicRead"
# [END gaeflex_py_django_static_config]
# [END staticurl]
Expand Down
4 changes: 2 additions & 2 deletions appengine/flexible/django_cloudsql/polls/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from django.urls import re_path
from django.urls import path

from . import views

urlpatterns = [
re_path(r"^$", views.index, name="index"),
path("", views.index, name="index"),
]
4 changes: 2 additions & 2 deletions appengine/flexible/django_cloudsql/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==5.0.4; python_version >= "3.10"
Django==4.2.13; python_version < "3.10"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version >= "3.8" and python_version < "3.10"
gunicorn==22.0.0
psycopg2-binary==2.9.9
django-environ==0.11.2
Expand Down
21 changes: 3 additions & 18 deletions appengine/flexible/hello_world_django/project_name/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""project_name URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/stable/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import include, path

import helloworld.views


urlpatterns = [
url(r"^admin/", include(admin.site.urls)),
url(r"^$", helloworld.views.index),
path("admin/", include(admin.site.urls)),
path("", helloworld.views.index),
]
4 changes: 2 additions & 2 deletions appengine/flexible/hello_world_django/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==5.0.4; python_version >= "3.10"
Django==4.2.13; python_version >= "3.8" and python_version < "3.10"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
gunicorn==22.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from django.urls import re_path
from django.urls import path

from . import views

urlpatterns = [
re_path(r"^$", views.index, name="index"),
path("", views.index, name="index"),
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==5.0.4; python_version >= "3.10"
Django==4.2.13; python_version >= "3.8" and python_version < "3.10"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
gunicorn==22.0.0
psycopg2-binary==2.9.9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""project_name URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/stable/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.urls import include, path

import helloworld.views


urlpatterns = [
url(r"^admin/", include(admin.site.urls)),
url(r"^$", helloworld.views.index),
path("admin/", include(admin.site.urls)),
path("", helloworld.views.index),
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Django==5.0.4; python_version >= "3.10"
Django==5.0.3; python_version >= "3.10"
Django==4.2.13; python_version >= "3.8" and python_version < "3.10"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
gunicorn==22.0.0
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Django==5.0.7; python_version >= "3.10"
Django==4.2.8; python_version < "3.10"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version < "3.10"
django-environ==0.10.0
google-cloud-logging==3.5.0
appengine-python-standard>=0.2.3
appengine-python-standard>=0.2.3
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django==5.0.3; python_version >= "3.10"
Django==4.2.8; python_version >= "3.8" and python_version < "3.10"
Django==3.2.23; python_version < "3.8"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
django-environ==0.10.0
google-cloud-logging==3.5.0
appengine-python-standard>=0.3.1
appengine-python-standard>=0.3.1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from django.conf import settings
from django.core.wsgi import get_wsgi_application
from django.http import HttpResponse
from django.urls import path
from django.urls import re_path
from google.appengine.api import mail, wrap_wsgi_app

Expand Down Expand Up @@ -105,9 +106,9 @@ def receive_bounce(request):


urlpatterns = [
re_path(r"^$", home_page),
path("", home_page),
re_path(r"^_ah/mail/.*$", receive_mail),
re_path(r"^_ah/bounce$", receive_bounce),
path("_ah/bounce", receive_bounce),
]

settings.configure(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django==5.0.7; python_version >= "3.10"
Django==4.2.8; python_version >= "3.8" and python_version < "3.10"
Django==3.2.23; python_version < "3.8"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
django-environ==0.10.0
google-cloud-logging==3.5.0
appengine-python-standard>=0.2.3
appengine-python-standard>=0.2.3
6 changes: 3 additions & 3 deletions appengine/standard_python3/django/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django==5.0.3; python_version >= "3.10"
Django==4.2.8; python_version >= "3.8" and python_version < "3.10"
Django==3.2.23; python_version < "3.8"
Django==5.1; python_version >= "3.10"
Django==4.2.15; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
django-environ==0.10.0
psycopg2-binary==2.9.9
google-cloud-secret-manager==2.16.1
2 changes: 1 addition & 1 deletion kubernetes_engine/django_tutorial/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==5.0.4; python_version >= "3.10"
Django==5.1; python_version >= "3.10"
Django==4.2.13; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
# Uncomment the mysqlclient requirement if you are using MySQL rather than
Expand Down
11 changes: 8 additions & 3 deletions run/django/mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

Expand All @@ -170,8 +169,14 @@
# Define static storage via django-storages[google]
GS_BUCKET_NAME = env("GS_BUCKET_NAME")
STATIC_URL = "/static/"
DEFAULT_FILE_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
STATICFILES_STORAGE = "storages.backends.gcloud.GoogleCloudStorage"
STORAGES = {
"default": {
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
},
"staticfiles": {
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
},
}
GS_DEFAULT_ACL = "publicRead"
# [END cloudrun_django_static_config]

Expand Down
2 changes: 1 addition & 1 deletion run/django/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==5.0.4; python_version >= "3.10"
Django==5.1; python_version >= "3.10"
Django==4.2.13; python_version >= "3.8" and python_version < "3.10"
Django==3.2.25; python_version < "3.8"
django-storages[google]==1.14.2
Expand Down

0 comments on commit 3b1d83f

Please sign in to comment.