GAE:django-nonrel:没有名为 myapp.views 的模块

发布于 2024-10-15 09:15:16 字数 1509 浏览 5 评论 0原文

我在谷歌应用程序引擎上使用 django-nonrel 。

我在访问 http://localhost:8080/album 时遇到此问题

Could not import myapp.views. Error was: No module named myapp.views

我的网址:

urlpatterns = patterns('',
    ('^_ah/warmup$', 'djangoappengine.views.warmup'),
    ('^$', 'django.views.generic.simple.direct_to_template', {'template': 'home.html'}),
    (r'^album/$', 'myapp.views.view_albums'),
    (r'^admin/', include(admin.site.urls)),
)

我的观点:

def view_albums(request):
    return direct_to_template(request, 'album.html', locals())

部分设置:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'django.contrib.sessions',
    #    'django.contrib.sites',
    'djangotoolbox',

    # djangoappengine should come last, so it can override a few manage.py commands
    'djangoappengine',
)
PROJECT_DIR = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
ADMIN_MEDIA_PREFIX = '/media/admin/'
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
ROOT_URLCONF = 'urls'

我没有使用 django 的站点框架,应用程序结构是

myapp
  -\dbindexer
  -\django
  -\djangoappengine
  -\djangotoolbox
  -\media
  -\templates
  -__init__.py
  -app.yaml
  -views.py
  -urls.py
  -settings.py
  -models.py
  -manage.py
  -cron.yaml
  -dbindexes.py
...

I'm using django-nonrel on google app engine.

I've got this problem when visiting http://localhost:8080/album

Could not import myapp.views. Error was: No module named myapp.views

my urls:

urlpatterns = patterns('',
    ('^_ah/warmup

my views:

def view_albums(request):
    return direct_to_template(request, 'album.html', locals())

Part of Settings:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'django.contrib.sessions',
    #    'django.contrib.sites',
    'djangotoolbox',

    # djangoappengine should come last, so it can override a few manage.py commands
    'djangoappengine',
)
PROJECT_DIR = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
ADMIN_MEDIA_PREFIX = '/media/admin/'
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), 'templates'),)
ROOT_URLCONF = 'urls'

I'm not using django's site framework, the app structure is

myapp
  -\dbindexer
  -\django
  -\djangoappengine
  -\djangotoolbox
  -\media
  -\templates
  -__init__.py
  -app.yaml
  -views.py
  -urls.py
  -settings.py
  -models.py
  -manage.py
  -cron.yaml
  -dbindexes.py
...
, 'djangoappengine.views.warmup'), ('^

my views:


Part of Settings:


I'm not using django's site framework, the app structure is


, 'django.views.generic.simple.direct_to_template', {'template': 'home.html'}),
    (r'^album/

my views:


Part of Settings:


I'm not using django's site framework, the app structure is


, 'myapp.views.view_albums'),
    (r'^admin/', include(admin.site.urls)),
)

my views:

Part of Settings:

I'm not using django's site framework, the app structure is

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘年祭陌 2024-10-22 09:15:16

使用

我认为您正在urlconf 中

from myapp.views import *请尝试
-- 在 urlconf 中

从视图导入*

I think you are using

from myapp.views import * in urlconf

please try
-- in urlconf

from views import *

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文