Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appengine/flexible/django_cloudsql/noxfile_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
"ignored_versions": ["2.7", "3.7", "3.8", "3.10", "3.12", "3.13"],
"ignored_versions": ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"],
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
Expand Down
4 changes: 2 additions & 2 deletions appengine/flexible/django_cloudsql/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django==5.2.9
Django==6.0.1; python_version >= "3.12"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This change limits Django installation to Python 3.12+, which breaks the sample for users on older Python versions. To ensure broader compatibility, please specify Django versions for older Python versions as well.

Django==6.0.1; python_version >= "3.12"
Django==5.2.9; python_version < "3.12" and python_version >= "3.10"

gunicorn==23.0.0
psycopg2-binary==2.9.10
psycopg2-binary==2.9.11
django-environ==0.12.0
google-cloud-secret-manager==2.21.1
django-storages[google]==1.14.6
2 changes: 1 addition & 1 deletion appengine/flexible/hello_world_django/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ env: flex
entrypoint: gunicorn -b :$PORT project_name.wsgi

runtime_config:
python_version: 3
operating_system: "ubuntu24"
2 changes: 1 addition & 1 deletion appengine/flexible/hello_world_django/noxfile_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
"ignored_versions": ["2.7", "3.7"],
"ignored_versions": ["2.7", "3.7", "3.8", "3.9", "3.10", "3.11"],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
"enforce_type_hints": False,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@
# https://docs.djangoproject.com/en/stable/howto/static-files/

STATIC_URL = "/static/"

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
4 changes: 2 additions & 2 deletions appengine/flexible/hello_world_django/project_name/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# limitations under the License.

from django.contrib import admin
from django.urls import include, path
from django.urls import path

import helloworld.views


urlpatterns = [
path("admin/", include(admin.site.urls)),
path("admin/", admin.site.urls),
path("", helloworld.views.index),
]
2 changes: 1 addition & 1 deletion appengine/flexible/hello_world_django/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Django==5.2.9
Django==6.0.1; python_version >= "3.12"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This change limits Django installation to Python 3.12+, which breaks the sample for users on older Python versions. To ensure broader compatibility, please specify Django versions for older Python versions as well.

Django==6.0.1; python_version >= "3.12"
Django==5.2.9; python_version < "3.12" and python_version >= "3.10"

gunicorn==23.0.0
5 changes: 2 additions & 3 deletions kubernetes_engine/django_tutorial/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Django==5.2.9; python_version >= "3.10"
Django==4.2.24; python_version >= "3.8" and python_version < "3.10"
Django==6.0.1; python_version >= "3.12"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing the Django version specifications for older Python versions (3.8-3.11) is a breaking change for users of this sample. Please restore compatibility for these versions.

Django==6.0.1; python_version >= "3.12"
Django==5.2.9; python_version >= "3.10" and python_version < "3.12"
Django==4.2.24; python_version >= "3.8" and python_version < "3.10"

# Uncomment the mysqlclient requirement if you are using MySQL rather than
# PostgreSQL. You must also have a MySQL client installed in that case.
#mysqlclient==1.4.1
wheel==0.40.0
gunicorn==23.0.0; python_version > '3.0'
gunicorn==23.0.0; python_version < '3.0'
# psycopg2==2.8.4 # uncomment if you prefer to build from source
psycopg2-binary==2.9.10
psycopg2-binary==2.9.11
3 changes: 2 additions & 1 deletion run/django/e2e_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def deployed_service() -> str:
yield SERVICE

# Cleanup

"""
substitutions = [
f"_VERSION={SUFFIX},"
f"_SERVICE={SERVICE},"
Expand All @@ -142,6 +142,7 @@ def deployed_service() -> str:
]
+ substitutions
)
"""


@pytest.fixture
Expand Down
20 changes: 17 additions & 3 deletions run/django/e2e_test_setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ steps:
./retry.sh "gsutil mb \
-l ${_REGION} \
-p ${PROJECT_ID} \
-b off \
gs://${_STORAGE_BUCKET}"

- id: "IAM and Secrets"
Expand All @@ -57,14 +58,23 @@ steps:
GS_BUCKET_NAME=${_STORAGE_BUCKET}
SECRET_KEY=$(cat /dev/urandom | LC_ALL=C tr -dc '[:alpha:]' | fold -w 30 | head -n1)" > ${_SECRET_SETTINGS_NAME}

sa_email=$(gcloud projects list --filter "name=${PROJECT_ID}" --format "value(projectNumber)")-compute@developer.gserviceaccount.com
./retry.sh "gcloud iam service-accounts create ${_SERVICE_ACCOUNT_NAME}"

./retry.sh "gcloud projects add-iam-policy-binding ${PROJECT_ID} \
--member="serviceAccount:${_SERVICE_ACCOUNT_EMAIL} \
--role=rroles/iam.serviceAccountTokenCreator"

./retry.sh "gcloud iam add-iam-policy-binding ${_SECRET_SETTINGS_NAME} \
--member serviceAccount:${_SERVICE_ACCOUNT_EMAIL} \
--role roles/secretmanager.secretAccessor \
--project ${PROJECT_ID}"

./retry.sh "gcloud secrets create ${_SECRET_SETTINGS_NAME} \
--project $PROJECT_ID \
--data-file=${_SECRET_SETTINGS_NAME}"

./retry.sh "gcloud secrets add-iam-policy-binding ${_SECRET_SETTINGS_NAME} \
--member serviceAccount:${sa_email} \
--member serviceAccount:${_SERVICE_ACCOUNT_EMAIL} \
--role roles/secretmanager.secretAccessor \
--project ${PROJECT_ID}"

Expand Down Expand Up @@ -93,6 +103,7 @@ steps:
--set-cloudsql-instances ${_CLOUD_SQL_CONNECTION_NAME} \
--set-env-vars SETTINGS_NAME=${_SECRET_SETTINGS_NAME} \
--command migrate \
--service-account=${_SERVICE_ACCOUNT_EMAIL} \
--execute-now --wait"

- id: "Create Superuser"
Expand All @@ -109,6 +120,7 @@ steps:
--set-env-vars SETTINGS_NAME=${_SECRET_SETTINGS_NAME} \
--set-env-vars DJANGO_SUPERUSER_PASSWORD=${_ADMIN_PASSWORD} \
--set-env-vars DJANGO_SUPERUSER_EMAIL=${_ADMIN_EMAIL} \
--service-account=${_SERVICE_ACCOUNT_EMAIL} \
--execute-now --wait"

- id: "Deploy to Cloud Run"
Expand All @@ -123,6 +135,7 @@ steps:
--no-allow-unauthenticated \
--region ${_REGION} \
--set-cloudsql-instances ${_CLOUD_SQL_CONNECTION_NAME} \
--service-account=${_SERVICE_ACCOUNT_EMAIL} \
--set-env-vars SETTINGS_NAME=${_SECRET_SETTINGS_NAME}"

images:
Expand All @@ -148,4 +161,5 @@ substitutions:
_DB_PASS: password1234
_ADMIN_PASSWORD: superpass
_ADMIN_EMAIL: example@noop.com

_SERVICE_ACCOUNT_NAME: django-sa-${_VERSION}
_SERVICE_ACCOUNT_EMAIL: ${_SERVICE_ACCOUNT_NAME}@${PROJECT_ID}.iam.gserviceaccount.com
15 changes: 14 additions & 1 deletion run/django/mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,25 @@
STORAGES = {
"default": {
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
"options": {
"bucket_name": GS_BUCKET_NAME,
"querystring_auth": False,
"default_acl": True,
"expiration": 300,
},
},
"staticfiles": {
"BACKEND": "storages.backends.gcloud.GoogleCloudStorage",
"options": {
"bucket_name": GS_BUCKET_NAME,
"querystring_auth": True,
"default_acl": None,
"expiration": 300,
},
},
}
GS_DEFAULT_ACL = "publicRead"
GS_DEFAULT_ACL = None
GS_IAM_SIGN_BLOB = True
# [END cloudrun_django_static_config]

# Default primary key field type
Expand Down
2 changes: 1 addition & 1 deletion run/django/noxfile_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
"ignored_versions": ["2.7", "3.6", "3.7", "3.8"],
"ignored_versions": ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.14"],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature the
"enforce_type_hints": True,
Expand Down
5 changes: 2 additions & 3 deletions run/django/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Django==5.2.5; python_version >= "3.10"
Django==4.2.24; python_version >= "3.8" and python_version < "3.10"
Django==6.0.1; python_version >= "3.12"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing the Django version specifications for older Python versions (3.8-3.11) is a breaking change for users of this sample. Please restore compatibility for these versions.

Django==6.0.1; python_version >= "3.12"
Django==5.2.5; python_version >= "3.10" and python_version < "3.12"
Django==4.2.24; python_version >= "3.8" and python_version < "3.10"

django-storages[google]==1.14.6
django-environ==0.12.0
psycopg2-binary==2.9.10
psycopg2-binary==2.9.11
gunicorn==23.0.0
google-cloud-secret-manager==2.21.1