我有以下表格:
class SourceForm(forms.ModelForm):
class Meta:
model = Source
widgets = {
'category_re': forms.TextInput(),
'thumb_re': forms.TextInput(),
'movie_re': forms.TextInput()
}
def clean_url(self):
data = self.cleaned_data['url']
return helpers.url_fix(data)
和以下观点:
def source_form(request, id):
source = get_object_or_404(Source, pk=id)
form = SourceForm(request.POST or None, instance=source)
if form.is_valid():
form.save()
return render_to_response('source/form.html', {'form': form, 'source': source},
context_instance=RequestContext(request))
我有问题。字段的清理值url
未显示在表单中。我只看到旧的,没有修改过的值,但后来我尝试{{ form.cleaned_data }}
在模板中添加 - 它显示了正确的值。为什么会这样?我该如何解决?
蒂亚!