部署 Django 项目:文件夹/项目结构
我在 eclipse 中的 django 项目具有以下项目结构:
main-project-folder/
src/
main-app/
app1/
app2/
settings.py
manage.py
urls.py
__init__.py
media/
templates/
我可以使用此结构部署项目吗?换句话说,将 src 和其他文件夹(媒体、模板等)放在我的服务器的根文件夹(链接我的域的位置)中是正确的方法吗?
像:
my-server-folder/
src/
media/
...
我想在 my-server-folder 中我应该放置项目的入口点,但是在我的项目中我在 main-project-folder 中没有入口点,或者 django 会自动重定向到src/main-app 文件夹的入口点(我认为它不是,因为我没有找到任何让 django 执行此操作的选项)?
My django project in eclipse has this project structure:
main-project-folder/
src/
main-app/
app1/
app2/
settings.py
manage.py
urls.py
__init__.py
media/
templates/
Can i deploy the project with this structure? In other words, is right way to put src and other folders (media, tempaltes, etc.) in the root folder of my server (where my domain is linked)?
Like:
my-server-folder/
src/
media/
...
I imagine that in my-server-folder i should put the entry point of project, but in my project i haven't an entry point in main-project-folder, or does django automatically redirect to an entry point of src/main-app folder (i think that it doesn't because i don't find any options that say to django to do it)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然。这是一个很好的目录结构。
请记住,除非您告诉,否则您的 Web 服务器不会知道如何处理 Django 项目。如果您的 Web 服务器是 Apache(如果您不知道,可能就是 Apache),请在此处查找有关设置它以运行 Django 应用程序的说明:
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/
这里是WSGI:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
Django 应用程序与 PHP 不同,您只需将它们上传到 Web 服务器即可运行。
Sure. That's a fine directory structure.
Keep in mind your web server isn't going to know what to do with the Django project unless you tell it. If your web server is Apache (which it probably is if you don't know) look here for instructions to set it up to run the Django app:
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/
And here for WSGI:
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
Django apps aren't like PHP where you just upload them to the web server and they work.