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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Configuring A Static Asset Pipeline With Django And Heroku

24 点作者 larkinrichards大约 12 年前

3 条评论

nulluk大约 12 年前
Instead of prefixing everything with {{ STATIC_URL }} in your templates, use the template tag {% static 'foo/bar/img' %} which will allow you to do asset time-stamping/versioning,<p><a href="https://docs.djangoproject.com/en/dev/howto/static-files/#with-a-template-tag" rel="nofollow">https://docs.djangoproject.com/en/dev/howto/static-files/#wi...</a><p>Edit: forgot to link to the versioning part in the docs: <a href="https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#cachedstaticfilesstorage" rel="nofollow">https://docs.djangoproject.com/en/dev/ref/contrib/staticfile...</a><p>Edit edit: ADMIN_MEDIA_PREFIX is also depreciated from 1.4 onwards: <a href="https://docs.djangoproject.com/en/1.4/releases/1.4/#django-contrib-admin" rel="nofollow">https://docs.djangoproject.com/en/1.4/releases/1.4/#django-c...</a>
评论 #5294283 未加载
arocks大约 12 年前
&#62; Unfortunately, Heroku’s guide on using Django and static files has no actual details on how you should configure Django to serve static files<p>This is of course because Django <i>should not</i> be used for serving static files in production. It is has to be handled before it reaches the Application layer i.e. by the web server.<p>Before Amazon S3 and CloudFront, it used to be the job of Apache or Nginx to serve static content but now that we have cloud based solutions they would be more robust. So it makes sense not to include such production deployment details from Django docs. But it is incredibly useful to have a stand-in functionality while you are in development.
route3大约 12 年前
Lots of useful information here and kudos to the author for composing a well-written post: summary of the issue, "here's how we fixed it" (with code samples) and concludes with some caveats/things to watch for. (Reminder: quality content like this is how inbound marketing works)<p>IMHO the official Django docs are some of the best you'll find anywhere of any open source project. My suggestion, though, is to read and re-read and make sure you gather all documented information about $YOUR_TOPIC before formulating your own game plan. For example, here is the chapter on handling static assets in Django:<p><a href="https://docs.djangoproject.com/en/dev/howto/static-files/" rel="nofollow">https://docs.djangoproject.com/en/dev/howto/static-files/</a><p>There are a lot of relevant links on that page that are worth following if you want to make sure you a) get the picture and b) know how you want it to all come together for your project.<p>Lastly, on the topic of storing assets: if you want to offer a Django-ready library for your new cloud storage startup/setup, consider writing your own file storage handler<p><a href="https://docs.djangoproject.com/en/dev/howto/custom-file-storage/" rel="nofollow">https://docs.djangoproject.com/en/dev/howto/custom-file-stor...</a>