Search code examples
mysqldjangodjango-oscar

Django Oscar "ProgrammingError at /admin/" MySQL table


Trying to make my second Django app: a shop based on Django Oscar. I'm following the tutorial on RTFD. I have an issue with this stage http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html#creating-product-classes-and-fulfillment-partners.

Every Oscar deployment needs at least one product class and one fulfillment partner. These aren’t created automatically as they’re highly specific to the shop you want to build. The quickest way to set them up is to log into the Django admin interface at localhost:8000/admin/ and create instances of both there. For a deployment setup, we recommend creating them as data migration.

However when I try to log into the admin the error generated is:

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

This template is shown in the error with this line highlighted:

 <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 %}">

So it looks like I'm missing a table. I'm using MySQL as the database. In the mysql prompt I tried the obvious..

mysql> CREATE TABLE winestoreoscar.django_admin_log;

but got the error message...

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

I then tried removing the whole for loop in the admin template, and admin rendered successfully, but attempting to save resulted in the previous error.

Now I'm stuck. Any help very much appreciated.

Edit: Here's the tree from the base dir (Thinks - do I need an 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

my urls.py is

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)),
]

Solution

  • You need to create the tables with syncdb and migrate, as per the docs:

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

    Have you done that?