TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Django Secret Key Generator

5 点作者 ariestiyansyah将近 9 年前

6 条评论

franciscop将近 9 年前
I am getting the feeling this is not a real project but a joke/critique
bwackwat将近 9 年前
&gt;import os<p>&gt;os.urandom(24)<p>&#x27;\x17\x96e\x94]\xa0\xb8\x1e\x8b\xee\xdd\xe9\x91^\x9c\xda\x94\t\xe8S\xa1Oe_&#x27;<p>&gt;os.urandom(24).encode(&#x27;hex&#x27;)<p>&#x27;cd48e1c22de0961d5d1bfb14f8a66e006cfb1cfbf3f0c0f3&#x27;
评论 #12256208 未加载
afshinmeh将近 9 年前
and there is a thing in Python called __future__ so you don&#x27;t need to do this:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;ariestiyansyah&#x2F;django-secret-key&#x2F;blob&#x2F;master&#x2F;django-secret-key#L10" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ariestiyansyah&#x2F;django-secret-key&#x2F;blob&#x2F;mas...</a><p>Read more: <a href="https:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;library&#x2F;__future__.html" rel="nofollow">https:&#x2F;&#x2F;docs.python.org&#x2F;2&#x2F;library&#x2F;__future__.html</a>
评论 #12256400 未加载
sold将近 9 年前
Since Django 1.10 you can simply use get_random_secret_key in django.core.management.utils.<p>This will not work:<p>if python3: print (SECRET_KEY) else: print SECRET_KEY<p>because it&#x27;s a syntax error in Python 3. Instead, you can just write &quot;print (SECRET_KEY)&quot;, this works in both versions and has the same effect.
SEJeff将近 9 年前
Also, why not import string and use string.printable instead of hardcoding the characters? Or even:<p><pre><code> chars = string.ascii_lowercase + string.punctuation + string.digits</code></pre>
hatsunearu将近 9 年前
Care to explain what this is?