Thanks to visit codestin.com
Credit goes to github.com

Skip to content

modify middleware settings and url paths for django 2.0 #1503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 13, 2018

Conversation

hirokts
Copy link
Contributor

@hirokts hirokts commented May 26, 2018

Please check the django 2.0 middleware settings of the official document.

(pip requirements.txt: Django==2.0.3)

https://docs.djangoproject.com/en/2.0/topics/http/middleware/

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label May 26, 2018
@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels May 27, 2018
Copy link
Contributor

@dat-boris dat-boris left a comment

Choose a reason for hiding this comment

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

The tutorial at https://cloud.google.com/python/django/kubernetes-engine is currently broken. This PR fixes the issue.

For example, the wrong middleware causes an error when accessing Django admin console:

AttributeError: 'WSGIRequest' object has no attribute 'user'

@@ -21,11 +21,11 @@ FROM gcr.io/google_appengine/python

# Create a virtualenv for the application dependencies.
# # If you want to use Python 3, add the -p python3.4 flag.
RUN virtualenv /env
RUN virtualenv -p python3.4 /env
Copy link
Contributor

Choose a reason for hiding this comment

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

I bumped this to 3.6 and confirmed it works 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I changed the version.

@@ -21,11 +21,11 @@ FROM gcr.io/google_appengine/python

# Create a virtualenv for the application dependencies.
# # If you want to use Python 3, add the -p python3.4 flag.
Copy link
Member

Choose a reason for hiding this comment

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

We should change this comment, since python36 is preselected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I changed it.

@andrewsg
Copy link
Member

Do the docs specify that python 3.6 specifically is used for this sample code? Is there a way we can write it to be a little more version-agnostic, for instance using -p python3 instead of 3.6?

@hirokts
Copy link
Contributor Author

hirokts commented Jun 20, 2018

I confirmed it's ok to do so.
The reason of this PR is "middleware settings needs to be changed due to differences in version of django", I prefer declarative version specification. Although, assuming automatically updating the version of django (in pip requirements text) or python (in docker image), it's better to use "-p python3" or "python3 -m venv".

@andrewsg
Copy link
Member

We do often update versions of dependencies such as Django as part of our maintenance (via bots). Given that, should we change it to -p python3 or do you think it should stay as it is?

@morenoh149
Copy link

I fixed these issues myself. I also had to make the changes described here https://gist.github.com/morenoh149/39be1ace1f99b9571fd2b6b96098075d I could submit these as a separate PR but may make logical sense to include in this PR

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels Jun 21, 2018
@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Jun 21, 2018
@hirokts
Copy link
Contributor Author

hirokts commented Jun 21, 2018

Thanks.
Thinking about the situation, I changed python version specification.

I think it's better to change url path settings for django 2.
https://docs.djangoproject.com/en/2.0/ref/urls/
I changed to use django.urls .

@hirokts hirokts changed the title modify middleware settings modify middleware settings and url paths for django 2.0 Jun 21, 2018
@morenoh149
Copy link

lgtm

@hirokts
Copy link
Contributor Author

hirokts commented Jul 5, 2018

@andrewsg , could you check this PR? Editing my comment may have been wrong if you did not notice the PR changing.

@andrewsg
Copy link
Member

lgtm. Thanks!

@andrewsg andrewsg merged commit 47a39cc into GoogleCloudPlatform:master Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants