问题1
{% scrf_token %}
'scrf_token', expected 'endblock'. Did you forget to register or load this tag?
{% scrf_token %}
'scrf_token', expected 'endblock'. Did you forget to register or load this tag?
解决方法:
代码出现问题
{% csrf_token %}
问题2
SyntaxError: invalid syntax. Perhaps you forgot a comma?
SyntaxError: invalid syntax. Perhaps you forgot a comma?
解决方法:
忘记了逗号 (,),在衔接处补充逗号
问题3
django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form EntryForm needs updating.
django.core.exceptions.ImproperlyConfigured: Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form EntryForm needs updating.
故障原因---代码错误:
forms.py中
field = ['text']
修改后代码:
fields = ['text'](或者使用 fields = '__all__' 代替也是可以的)
问题4
NameError: name 'login_required' is not defined
NameError: name 'login_required' is not defined
解决方法:
添加模块导入
from django.contrib.auth.decorators import login_required