2

Don't mix *args and **kwargs in call to reverse()!尝试将 args 和 kwargs 传递给视图时出现错误。在这一点上,我已经尝试了很多事情,但无法理解这一点——完全停留在如何将两者都传递给视图。

我需要将两者都传递unipartnewfile另一个视图。

url(r'^(\d+)/(\d+)/convert/$', 'store.views.changetool', name = "convert"),
url(r'^(\d+)/view_part/$','store.views.view_part',name="view_part"),

VIEWS.PY(更改工具)

def changetool (request, id, unipart=None):
    part = Part.objects.get(id=id)
    file = str (part.content)
    newfile = FormatConversion.ConvertToNew(file)
    return redirect('view_part', unipart, newfile = newfile)

VIEWS.PY (view_part)

def view_part(request, part_id, newfile = None):
4

1 回答 1

3

你必须有这些进口:

from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect

你的return陈述应该是:

return HttpResponseRedirect(
    reverse('path.to.function.view_part', args=(unipart, newfile))
)

相关文档在这里

于 2013-07-03T18:53:42.713 回答