0

我正在使用南,我有syncdb,但是我被这个数据库错误卡住了,你能帮我解决这个问题,也许告诉我将来如何解决这样的问题。

这个丢失的数据库表错误正在几个不同的地方出现,处理名为 salesflow_contact 的东西

显示的错误是由于尝试将一些内容发布到表格,但我也得到了分页视图浏览联系人的错误

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/addacontact

Django Version: 1.4.2
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'south',
 'sekizai')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/brian/projects/steprider/steprider/views.py" in Add_a_contact
  36.           new_contact = form.save(request.user)
File "/home/brian/projects/steprider/salesflow/forms.py" in save
  23.       contact.save()
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/base.py" in save
  463.         self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/base.py" in save_base
  551.                 result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/manager.py" in _insert
  203.         return insert_query(self.model, objs, fields, **kwargs)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/query.py" in insert_query
  1593.     return query.get_compiler(using=using).execute_sql(return_id)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/sql/compiler.py" in execute_sql
  909.         for sql, params in self.as_sql():
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/sql/compiler.py" in as_sql
  872.                 for obj in self.query.objs
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/django_extensions-0.9-py2.7.egg/django_extensions/db/fields/__init__.py" in pre_save
  135.         value = unicode(self.create_slug(model_instance, add))
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/django_extensions-0.9-py2.7.egg/django_extensions/db/fields/__init__.py" in create_slug
  122.         while not slug or queryset.filter(**kwargs):
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/query.py" in __nonzero__
  130.             iter(self).next()
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/query.py" in _result_iter
  118.                 self._fill_cache()
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/query.py" in _fill_cache
  892.                     self._result_cache.append(self._iter.next())
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/query.py" in iterator
  291.         for row in compiler.results_iter():
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/sql/compiler.py" in results_iter
  763.         for rows in self.execute_sql(MULTI):
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/models/sql/compiler.py" in execute_sql
  818.         cursor.execute(sql, params)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/backends/util.py" in execute
  40.             return self.cursor.execute(sql, params)
File "/home/brian/virt_env/virt_step/local/lib/python2.7/site-packages/Django-1.4.2-py2.7.egg/django/db/backends/sqlite3/base.py" in execute
  344.             return Database.Cursor.execute(self, query, params)

Exception Type: DatabaseError at /addacontact
Exception Value: no such table: salesflow_contact


#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  steprider.salesflow.forms.py
#  
#  Copyright 2012 BRIAN SCOTT CARPENTER <KlanestroTalisman@gmail.com>

from django.forms import ModelForm
from salesflow import models
from django import forms
from django.template.defaultfilters import slugify

class ContactForm(ModelForm):
    description = forms.CharField(widget=forms.Textarea)

    class Meta:
        model = models.Contact
        exclude = ("user","slug")

    def save(self, user):
        contact = super(ContactForm, self).save(commit=False)
        contact.user = user
        contact.save()
        return contact

class Contact_History_Form:

    class Meta:
        model = models.Contact_History
        exclude = ("user","slug")






#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  views.py
#  
#  Copyright 2012 BRIAN SCOTT CARPENTER <KlanestroTalisman@gmail.com>
from django.shortcuts import render_to_response,get_object_or_404
from django.template import RequestContext
from salesflow.forms import *
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from salesflow.models import Contact

def home (request):
    """ This is the Home view"""
    return render_to_response(('index.html') ,context_instance=RequestContext(request))


def server_error(request, template_name='templates/500.html'):
    """
    500 error handler.
    Templates: `500.html`
    Context:
    STATIC_URL
      Path of static media (e.g. "media.example.org")
    """
    t = loader.get_template(template_name)
    return HttpResponseServerError(
        t.render(Context({'STATIC_URL': settings.STATIC_URL})))

def Add_a_contact(request):
    """give them a page so they can donate and save it to a database."""
    if request.method == 'POST':
        form = ContactForm(request.POST,request.FILES)
        if form.is_valid():
            new_contact = form.save(request.user)
            return HttpResponseRedirect(reverse(item, args=(new_contact.slug,)))
    else:
        form = ContactForm()
    return render_to_response('salesflow/addacontact.html',{'form': form},context_instance=RequestContext(request))

def browse_contacts(request):
    contact_list = Contact.objects.all()
    paginator = Paginator(contact_list,15)

    page = request.GET.get('page')

    try:
        contacts = paginator.page(page)
    except PageNotAnInteger:
        # If page is not an integer, deliver first page.
        contacts = paginator.page(1)
    except EmptyPage:
        # If page is out of range (e.g. 9999), deliver last page of results.
        contacts = paginator.page(paginator.num_pages)

    return render_to_response('salesflow/browsecontacts.html',
    {"contacts":contacts,
    "site":settings.SITE_DOMAIN},
    context_instance=RequestContext(request))
4

1 回答 1

2

错误很简单。你没有表叫salesflow_contact

您需要运行migrate假设它具有初始的schemamigration salesflow --initial第一个表创建迁移。

syncdb不会为南方管理模型创建表,这很可能是您的问题。您可以绕过它,syncdb --all但如果它是真正由南方管理的,您应该运行并且假设您在那里进行迁移,migrate salesflow它应该创建表。schemamigration salesflow --initial

于 2012-10-25T01:15:22.900 回答