Mysql没有更新表中的值

时间:2014-11-29 04:32:43

标签: python mysql django

我正在使用MySQL工作台进行Python Django项目。单击我的应用程序中的一个搜索按钮时,我最初收到以下错误:

DatabaseError at /search/results/mobiles/
  (1214, "The used table type doesn't support FULLTEXT indexes")

然后我通过发出查询将数据库引擎从INNODB更改为MYISAM

SET GLOBAL default_storage_engine=MYISAM;

超过原始错误。但是现在如果我在Django管理UI(localhost:8000 / admin)中进行更改,MySQL表值不会被更改。我该如何解决这个问题?

这是我的search_category和search_result定义:

def search_in_category(request, slug):
    # reset the search params, if present
    try:
        del request.session['search']
    except KeyError:
        pass

    return search_results(request, slug)

def search_results(request, slug):
category = get_object_or_404(Category, slug=slug)
fields = list(category.field_set.all())
fields += list(Field.objects.filter(category=None))
fieldsLeft = [field.name for field in fields]

if request.method == "POST" or 'search' in request.session:
    ads = category.ad_set.filter(active=True,
                                 expires_on__gt=datetime.datetime.now())
    # A request dictionary with keys defined for all
    # fields in the category.
    post = {}
    if 'search' in request.session:
        post.update(request.session['search'])
    else:
        post.update(request.POST)

    sforms = prepare_sforms(fields, fieldsLeft, post)

    isValid = True

    for f in sforms:
        # TODO: this assumes the form is not required
        # (it's a search form after all)
        if not f.is_valid() and not f.is_empty():
            isValid = False

    if isValid:
        if request.method == 'POST':
            request.session['search'] = {}
            request.session['search'].update(request.POST)
            return redirect('classifieds_browse_search_results', slug=slug)

        for f in sforms:
            ads = f.filter(ads)

        if ads.count() == 0:
            return render_to_response('classifieds/list.html',
                                      {'no_results': True,
                                       'category': category},
                                      context_instance=RequestContext(request))
        else:
            context = context_sortable(request, ads)
            context['category'] = category
            return render_to_response('classifieds/list.html', context,
                                      context_instance=RequestContext(request))
else:
    sforms = prepare_sforms(fields, fieldsLeft)

return render_to_response('classifieds/search.html',
                          {'forms': sforms, 'category': category},
                          context_instance=RequestContext(request))

2 个答案:

答案 0 :(得分:0)

错误是自解释的,您试图索引InnoDB中的FULLTEXT字段。问自己这个问题,计算机如何索引FULLTEXT字段?

InnoDB是一个很棒的引擎。

从FULLTEXT字段中删除索引以修复InnoDB引擎上发生的问题。

答案 1 :(得分:0)

将alter table改为MYISAM ==>之后此处提出的问题

您的桌子已被锁定,这就是为什么您无法通过管理员更改表格值的原因。首先使用以下命令检查您的表是否已锁定。

show open tables WHERE Table LIKE 'tb_geetha' AND In_use > 0

如果lockedmysql> UNLOCK TABLES;