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

Skip to content

Added Django sample for App Engine Python 3.7 standard runtime #1720

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 6 commits into from
Oct 1, 2018

Conversation

michaelawyu
Copy link
Contributor

No description provided.

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 24, 2018
.gitignore

# Python pycache:
__pycache__/
Copy link
Member

Choose a reason for hiding this comment

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

nit: add newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,16 @@
# [START django_app]
runtime: python37
entrypoint: gunicorn -b :$PORT mysite.wsgi
Copy link
Member

Choose a reason for hiding this comment

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

Is there any way we can do this without specifying a manual entrypoint, instead using the default entrypoint?

If there is not (I know Django is more challenging in this respect) then please change this entrypoint line to add multiple workers and threads. We should make every effort to use the default without an entrypoint though, even if it is awkward.

# the entire handlers section) when there are no static files defined.
- url: /.*
script: auto
# [END django_app]
Copy link
Member

Choose a reason for hiding this comment

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

nit: add newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'lldtg$9(wi49j_hpv8nnqlh!cj7kmbwq0$rj7vy(b(b30vlyzj'
Copy link
Member

Choose a reason for hiding this comment

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

Do our other Django samples hardcode a secret key like this? It seems like we should have a replace-me placeholder or something, but you can follow the lead of our other Django samples if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, our App Engine Python 2.7 Django sample uses the sample pattern as well. I will add a comment to remind developers of changing the secret key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added. Weirdly the snapshot won't refresh :(


INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
Copy link
Member

Choose a reason for hiding this comment

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

Are all these contrib apps used? I'm not sure whether or not we should include them if they are unused. We can follow the lead of our other Django samples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Andrew, in this tutorial I just used the default set of contrib apps listed in the Django getting started tutorial (https://docs.djangoproject.com/en/2.1/intro/tutorial02/); I can remove the unused ones if required though.

from .models import Question, Choice

admin.site.register(Question)
admin.site.register(Choice)
Copy link
Member

Choose a reason for hiding this comment

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

nit: add newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

</ul>
{% else %}
<p>No polls are available.</p>
{% endif %}
Copy link
Member

Choose a reason for hiding this comment

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

nit: add newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

# Always return an HttpResponseRedirect after successfully dealing
# with POST data. This prevents data from being posted twice if a
# user hits the Back button.
return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))
Copy link
Member

Choose a reason for hiding this comment

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

nit: add newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,2 @@
Django==2.1.1
mysqlclient==1.3.13
Copy link
Member

Choose a reason for hiding this comment

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

Can we use pymysql here instead? We're trying to standardize on that across our samples as complaints about installing mysql dev libs are very common.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Done.

@michaelawyu michaelawyu changed the title [DO NOT MERGE] Added Django sample for App Engine Python 3.7 standard runtime Added Django sample for App Engine Python 3.7 standard runtime Oct 1, 2018
@michaelawyu michaelawyu merged commit b561761 into master Oct 1, 2018
@michaelawyu michaelawyu deleted the michaelawyu-patch-appengine-py37-django branch October 11, 2018 23:27
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.

3 participants