Django Oscar“ProgrammingError at / admin /”MySQL表

时间:2014-09-01 14:26:03

标签: mysql django django-oscar

尝试制作我的第二个Django应用程序:基于Django Oscar的商店。我正在关注RTFD的教程。我对此阶段http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html#creating-product-classes-and-fulfillment-partners有疑问。

  

每次奥斯卡部署至少需要一个产品类别和一个产品类别   履行伙伴。这些不是自动创建的   非常适合您想要建造的商店。最快捷的设定方式   他们是登录Django管理界面   localhost:8000 / admin /并创建两者的实例。为一个   部署设置,我们建议将它们创建为数据迁移。

但是当我尝试登录管理员时,生成的错误是:

ProgrammingError at /admin/

(1146, "Table 'winestoreoscar.django_admin_log' doesn't exist")
....
Error during template rendering

In template /home/david/.virtualenvs/winestoreoscar/local/lib/python2.7/site-packages/django/contrib/admin/templates/admin/index.html, error at line 65
1146

此模板显示在错误中,此行突出显示:

 <ul class="actionlist">
**65    {% for entry in admin_log %}**
66  <li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">

所以看起来我错过了一张桌子。我正在使用MySQL作为数据库。在mysql提示符中我尝试了明显的..

mysql> CREATE TABLE winestoreoscar.django_admin_log;

但收到了错误消息......

ERROR 1113 (42000): A table must have at least 1 column

然后我尝试在管理模板中删除整个for循环,并且admin成功渲染,但尝试保存导致上一个错误。

现在我被卡住了。任何帮助非常感谢。

编辑: 这是基础目录中的树(想想 - 我需要一个admin.py ..?):

├── manage.py
└── oscarwinestore
    ├── __init__.py
    ├── __init__.pyc
    ├── settings.py
    ├── settings.py~
    ├── settings.pyc
    ├── urls.py
    ├── urls.py~
    ├── urls.pyc
    ├── wsgi.py
    └── wsgi.pyc

我的urls.py是

from django.conf.urls import include, url
from oscar.app import application
from django.contrib import admin
admin.autodiscover()

urlpatterns = [
    url(r'^i18n/', include('django.conf.urls.i18n')),

    # The Django admin is not officially supported; expect breakage.
    # Nonetheless, it's often useful for debugging.
    url(r'^admin/', include(admin.site.urls)),

    url(r'', include(application.urls)),
]

1 个答案:

答案 0 :(得分:1)

您需要根据the docs创建包含syncdbmigrate的表格:

$ python manage.py syncdb --noinput
$ python manage.py migrate

你做到了吗?