我正在使用django_smart_select软件包。我在尝试使用链式选择选项的模型中收到以下错误。
AttributeError at /admin/tags/tag/add/
'bool' object has no attribute 'startswith'
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/tags/tag/add/
Django Version: 1.11.4
Exception Type: AttributeError
Exception Value:
'bool' object has no attribute 'startswith'
Error during template rendering
In template C:\Users\gautammandewalker\Envs\django01\lib\site-
packages\django\contrib\admin\templates\admin\base.html, error at line 3
'bool' object has no attribute 'startswith'
1 {% load i18n static %}<!DOCTYPE html>
2 {% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi
as LANGUAGE_BIDI %}
3 <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI
%}dir="rtl"{% endif %}>
4 <head>
5 <title>{% …Run Code Online (Sandbox Code Playgroud) 以下是我的模型:
class Product(models.Model):
product_title = models.CharField(max_length=100, null=False,
verbose_name='Product title')
product_description = models.TextField(max_length=250,
verbose_name='Product description')
product_qty = models.IntegerField(verbose_name='Quantity')
product_mrp = models.FloatField(verbose_name='Maximum retail price')
product_offer_price = models.FloatField(verbose_name='Selling price')
def validate_produce_offer_price(sender, instance, **kwargs):
if instance.product_offer_price > instance.product_mrp:
from django.core.exceptions import ValidationError
raise ValidationError('Product offer price cannot be greater than
Product MRP.')
pre_save.connect(validate_produce_offer_price, sender=Product)
Run Code Online (Sandbox Code Playgroud)
我想在保存模型之前验证product_offer_price.验证错误正在成功引发,但是在调试器创建的异常页面上.如何在管理员本身的表单上显示错误,就像管理表单提出的其他错误一样?