2014-11-14 41 views
9

我有一個projectfolder結構是這樣的:應用中的子文件夾在1.7

project 
    applications 
     __init__.py 
     app1 
     app2 
     app3 
    project 
     __init__.py 
     settings.py 

在我的settings.py我試着導入這樣的應用:

INSTALLED_APPS = (
    'django.contrib.admin', 
    ... 

    'applications.app1', 
    'applications.app2', 
    'applications.app3', 
) 

但是,如果我試圖將遷移應用程序之一,我得到這個錯誤:

./manage.py makemigrations applications.app1 
App 'applications.app1' could not be found. Is it in INSTALLED_APPS? 

出了什麼問題?這種設置的使用Django的工作1.6

回答

-1

是您PYTHONPATH應用程序文件夾?

你可以將這個標籤之下BASE_DIR在設置文件中添加:

import sys 
sys.path.append(os.path.abspath("applications")) 
+0

太棒了!謝謝! –

+0

davidhwang解釋正確的解決方案。 – pymarco

6

有實際上是一個Django的本地解決這個。來自docs

Many commands take a list of 「app names.」 An 「app name」 is the basename of the package containing your models. For example, if your INSTALLED_APPS contains the string 'mysite.blog', the app name is blog.

相關問題