这是我的申请表
from django import forms
from .models import Post
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = '__all__'
def clean_slug(self):
return self.cleaned['slug'].lower()
以下是我的Traceback:
Traceback (most recent call last):
File "django\core\handlers\exception.py", line
56, in inner
response = get_response(request)
File "django\core\handlers\base.py", line 197,
in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "django\views\generic\base.py", line 103,
in view
return self.dispatch(request, *args, **kwargs)
File "django\views\generic\base.py", line 142,
in dispatch
return handler(request, *args, **kwargs)
File "E:\Django Unleashed\suorganizer\blog\views.py", line 28, in post
if bound_form.is_valid():
File "django\forms\forms.py", line 205, in is_valid
return self.is_bound and not self.errors
File "django\forms\forms.py", line 200, in errors
self.full_clean()
File "django\forms\forms.py", line 437, in full_clean
self._clean_fields()
File "django\forms\forms.py", line 452, in _clean_fields
value = getattr(self, "clean_%s" % name)()
File "suorganizer\blog\forms.py", line 11, in clean_slug
return self.cleaned['slug'].lower()
AttributeError: 'PostForm' object has no attribute 'cleaned'
[26/Apr/2023 14:51:24] "POST /blog/create/ HTTP/1.1" 500 93820
2条答案
按热度按时间iqih9akk1#
变更:
对此:
gpfsuwkq2#
试试这个,我想它会解决你的问题: