使用 Django EAV 2 时出现错误“没有足够的值来解压(预期 2,得到 0)”

问题描述 投票:0回答:1
from django.contrib import admin

from .models import Product

from eav.forms import BaseDynamicEntityForm

from eav.admin import BaseEntityAdmin

Register your models here.

class ProductAdminForm(BaseDynamicEntityForm):
      model = Product

class ProductAdmin(BaseEntityAdmin):
      form = ProductAdminForm

admin.site.register(Product, ProductAdmin)

出现错误:

  1. 请求方式:GET
  2. 请求网址:http://127.0.0.1:8000/admin/shop/product/add/
  3. Django 版本:5.1.1
  4. 异常类型:ValueError
  5. 异常值:没有足够的值来解包(预期为 2,实际为 0)
  6. 异常 位置:C:\Users\iskander\Desktop\shop env\Lib\site-packages\django orms\widgets.py, 第 772 行,在 _choice_has_empty_value
  7. 在以下期间引发:django.contrib.admin.options.add_view
Error during template rendering

In template C:\Users\iskander\Desktop\shop\venv\Lib\site-packages\django\contrib\admin
\templates\admin\includes\fieldset.html, error at line 25

<div>
16 {% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}
17 <div class="flex-container{% if not line.fields|length == 1 %} fieldBox{% if field.field.name %}    field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}{% endif %}{% if field.is_checkbox %} checkbox-row{% endif %}">
18 {% if field.is_checkbox %}
19  {{ field.field }}{{ field.label_tag }}
20  {% else %}
21    {{ field.label_tag }}
22     {% if field.is_readonly %}
23       <div class="readonly">{{ field.contents }}</div>
24   {% else %}
25         **{{ field.field }}**
26    {% endif %}
27    {% endif %}
28          </div>
29    {% if field.field.help_text %}
30         <div class="help"{% if field.field.id_for_label %} 
                id="{{ field.field.id_for_label }}_helptext"{% endif %}>
31          <div>{{ field.field.help_text|safe }}</div>
32          </div>
33       {% endif %}
34       </div>
35  {% endfor %}

我之前尝试安装过,一切正常,但这次不行。我是初学者,正在学习 django

python django django-models
1个回答
0
投票

将 django-eav2 版本更改为 1.6.1

© www.soinside.com 2019 - 2024. All rights reserved.