python - 如何解决这个 django 网页问题
问题描述
我是 Django 的新手。我创建了一个名为 Programador 的应用程序,该应用程序与另一个名为 Proceso 的应用程序相关,当我尝试在管理网站中运行 App Programador 时,会显示下一个错误:
'builtin_function_or_method' object is not subscriptable
15 {% endif %}
16 </label>
17 <div class="{% if not line.fields|length_is:'1' %} col-auto fieldBox {% else %} col-sm-10 {% endif %}
18 {% if field.field.name %} field-{{ field.field.name }}{% endif %}
19 {% if not field.is_readonly and field.errors %} errors{% endif %}
20 {% if field.field.is_hidden %} hidden {% endif %}
21 {% if field.is_checkcard %} checkcard-row{% endif %}">
22 {% if field.is_readonly %}
23 <div class="readonly" style="margin-top: 7px;">{{ field.contents }}</div>
24 {% else %}
25 {{ field.field }}
26 {% endif %}
27 <div class="help-block red">
28 {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
29 </div>
30 {% if field.field.help_text %}
31 <div class="help-block">{{ field.field.help_text|safe }}</div>
32 {% endif %}
33 <div class="help-block text-red">
34 {% if line.fields|length_is:'1' %}{{ line.errors }}{% endif %}
35 </div>
这是来自 Programador 的代码:
import uuid
from django.db import models
from core.GestionTareasProgramadas.models.Proceso import Proceso
class Programador(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True, unique=True)
organizacion = models.CharField(verbose_name='Organización', max_length=100, null=True, blank=True)
estado = models.CharField(verbose_name='Organización', max_length=100, null=True, blank=True)
activo = models.BooleanField(verbose_name='Activo', null=True)
proceso_ID = models.ForeignKey(Proceso, on_delete=models.CASCADE, verbose_name='Proceso ID',blank=True, null=True)
programado = models.BooleanField(verbose_name='Activo', null=True)
fecha_inicio = models.DateField(verbose_name='Fecha inicio', null=True, blank=True)
hora_inicio = models.DateTimeField(verbose_name='Hora inicio', null=True, blank=True)
frecuencia = models.CharField(verbose_name='Frecuencia', max_length=100, null=True, blank=True)
intervalo = models.CharField(verbose_name='Intervalo', max_length=100, null=True, blank=True)
fecha_fin = models.DateField(verbose_name='Fecha fin', null=True, blank=True)
hora_fin = models.DateTimeField(verbose_name='Hora fin', null=True, blank=True)
def __str__(self):
return self.estado
class Meta:
verbose_name = "Programador"
verbose_name_plural = "Programadores"
db_table = 'core_programador_programador'
ordering = ['id']
以及来自 Proceso 的代码:
import uuid
from django.db import models
class Proceso(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False, unique=True, verbose_name='Uuid')
organizacion = models.CharField(verbose_name='Organización', max_length=100, null=True, blank=True)
activo = models.BooleanField(verbose_name='Activo', null=True)
indetificador = models.CharField(verbose_name='Identificador', max_length=100, null=True, blank=True)
nombre = models.CharField(verbose_name='Nombre', max_length=100, null=True, blank=True)
nombre_clase = models.CharField(verbose_name='Nombre Clase', max_length=100, null=True, blank=True)
def __str__(self):
return self.nombre
class Meta:
ordering = [id]
verbose_name = "Proceso"
verbose_name_plural = "Procesos"
db_table = 'core_programador_proceso'
管理员.py:
from django.contrib import admin
from core.GestionTareasProgramadas.models.Proceso import Proceso
from core.GestionTareasProgramadas.models.Programador import Programador
admin.site.register(Proceso)
admin.site.register(Programador)
有谁知道为什么我有这个错误?谢谢!