Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 47a39cc

Browse filesBrowse files
hiroktsandrewsg
authored andcommitted
modify middleware settings and url paths for django 2.0 (GoogleCloudPlatform#1503)
* modify middleware settings * Modify Python version to adjust with Django version * use python3.6 * modify the comment of virtualenv * modify the comment of virtualenv * modify python version for virtualenv * modify url path * modify importing of mysite/urls.py
1 parent 1fe1ca8 commit 47a39cc
Copy full SHA for 47a39cc

File tree

Expand file treeCollapse file tree

4 files changed

+11
-11
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+11
-11
lines changed

‎container_engine/django_tutorial/Dockerfile

Copy file name to clipboardExpand all lines: container_engine/django_tutorial/Dockerfile
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
FROM gcr.io/google_appengine/python
2121

2222
# Create a virtualenv for the application dependencies.
23-
# # If you want to use Python 3, add the -p python3.4 flag.
24-
RUN virtualenv /env
23+
# # If you want to use Python 2, use the -p python2.7 flag.
24+
RUN virtualenv -p python3 /env
2525
ENV PATH /env/bin:$PATH
2626

2727
ADD requirements.txt /app/requirements.txt
28-
RUN /env/bin/pip install -r /app/requirements.txt
28+
RUN /env/bin/pip install --upgrade pip && /env/bin/pip install -r /app/requirements.txt
2929
ADD . /app
3030

3131
CMD gunicorn -b :$PORT mysite.wsgi

‎container_engine/django_tutorial/mysite/settings.py

Copy file name to clipboardExpand all lines: container_engine/django_tutorial/mysite/settings.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,14 @@
4343
'polls'
4444
)
4545

46-
MIDDLEWARE_CLASSES = (
46+
MIDDLEWARE = (
47+
'django.middleware.security.SecurityMiddleware',
4748
'django.contrib.sessions.middleware.SessionMiddleware',
4849
'django.middleware.common.CommonMiddleware',
4950
'django.middleware.csrf.CsrfViewMiddleware',
5051
'django.contrib.auth.middleware.AuthenticationMiddleware',
51-
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
5252
'django.contrib.messages.middleware.MessageMiddleware',
5353
'django.middleware.clickjacking.XFrameOptionsMiddleware',
54-
'django.middleware.security.SecurityMiddleware',
5554
)
5655

5756
ROOT_URLCONF = 'mysite.urls'

‎container_engine/django_tutorial/mysite/urls.py

Copy file name to clipboardExpand all lines: container_engine/django_tutorial/mysite/urls.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
# limitations under the License.
1414

1515
from django.conf import settings
16-
from django.conf.urls import include, url
1716
from django.contrib import admin
1817
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
18+
from django.urls import include, path
19+
1920

2021
urlpatterns = [
21-
url(r'^', include('polls.urls')),
22-
url(r'^admin/', admin.site.urls)
22+
path('admin/', admin.site.urls),
23+
path('', include('polls.urls')),
2324
]
2425

2526
# Only serve static files from Django during development

‎container_engine/django_tutorial/polls/urls.py

Copy file name to clipboardExpand all lines: container_engine/django_tutorial/polls/urls.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from django.conf.urls import url
15+
from django.urls import path
1616

1717
from . import views
1818

1919
urlpatterns = [
20-
url(r'^$', views.index, name='index')
20+
path('', views.index, name='index')
2121
]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.