-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Conversation
.gitignore | ||
|
||
# Python pycache: | ||
__pycache__/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add newline
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add newline
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add newline
There was a problem hiding this comment.
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 %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add newline
There was a problem hiding this comment.
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,))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add newline
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Done.
No description provided.