且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Django和服务静态文件

更新时间:2023-02-26 22:01:42

是的Django使用的静态文件与管理员的图像,javascript和css几乎相关。所有其他静态内容来自您的应用程序。您可以将两个集合(您的和管理员)保留在同一台服务器下。只需在设置文件中设置相应的文件夹。





看到这篇文章了解更多信息:




I'm hosting a site on WebFaction using Django/mod_python/Python2.5. I've recently run into the concept of static files (when setting up my Django admin).

From what I understand, serving static files is simply the idea of telling the server to serve files directly from a specific directory, rather than first routing the request through apache, then mod_python, then django, and finally back to the user. In the case of WebFaction this helps especially since there are two Apache servers that your request must go through (your app's server and the main public server).

Why is it that when I setup Django's static files, it only needs the /media folder in /contrib/admin? Is it just that all of Django's static content is related to the admin panel?

When I want to serve my own static content (images, css, etc.) should I include it in the same /media folder or set up another alias for my own content (/my_media)?

Yes, the static files used by Django are pretty much related to images, javascript and css for the admin. All other static content comes from your application. You can keep both sets (yours and the admin) under the same server. Just set the appropriate folders in the settings file.

See this post for a little more information: