本文介绍了Heroku-Django:必须将对"myproject"的所有提及都更改为"app",以使我的网站正常运行.将来如何最好地避免这种情况?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Heroku上第一次运行了用Django1.3创建的网站.为了使我的网站在没有importError的情况下运行,我不得不将对myproject的所有提及都更改为app(例如,将import myproject.core.views更改为urls.py中的import app.core.views).

I just ran my website made with Django1.3 for the first time on Heroku. I had to change every mentioning of myproject into app(such as import myproject.core.views into import app.core.views in urls.py ) in order to make my website run without an importError.

我认为:

  • 我将Heroku目录($ heroku run pwd输出/app)/app更改为/myproject.我该怎么做呢?
  • 使用通用前缀.我将如何最好地做到这一点?
  • 我应该从较低的目录下推项目吗?
  • I change the Heroku directory ($ heroku run pwd ouputs /app) /app into /myproject. How do I do this?
  • Use a general prefix. How would I would I do this the best way?
  • I should push my project from a directory lower?

更新

这是我的本地和heroku目录的文件结构: gist.github.com/3361637

This is the file structure of my local and heroku directory: gist.github.com/3361637

以下是我必须在urls.py中进行的更改的示例: gist.github.com/3361686

Here is an example of the changes I had to make in urls.py: gist.github.com/3361686

其他文件的更改完全相同,只是更改了我的项目的名称

The changes for the other files were exactly the same, just changing the name of my project

Update2

前往mipadi:

在您建议的结构旁边,我从中更改了.git文件夹:

Next to your proposed structure I changed my .git folder from this:

.
|-- myproject_django
    |-- core
        # etc.
    |-- manage.py
    |-- .git
    # etc
|-- requirements.txt

对此:

.
|-- myproject_django
    |-- core
        # etc.
    |-- manage.py
    # etc
|-- requirements.txt
|-- .git

并将更改推送到heroku.但是现在,文件夹/文件已与以前的结构混合在一起.我试图使用heroku run rm file_name删除这些文件,但这不起作用.有什么想法吗?

and pushed the changes to heroku. But now the folders/files are mixed with the previous structure. I tried to delete these files using heroku run rm file_name but this doesn't work. Any ideas?

推荐答案

根据Heroku的说明(以及我设置的每个Django/Heroku项目),Django project 应该位于顶部级别,因此,就您而言,是这样:

According to Heroku's instructions (and every Django/Heroku project I've set up), the Django project should be at the top level, so, in your case, this:

.
|-- pykaboo_django
    |-- core
        # etc.
    |-- manage.py
    # etc
|-- requirements.txt

然后,您只需按应用名称导入即可:

Then, you can just import by app name:

from core.models import *

这篇关于Heroku-Django:必须将对"myproject"的所有提及都更改为"app",以使我的网站正常运行.将来如何最好地避免这种情况?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:59