【发布时间】:2014-03-04 07:45:37
【问题描述】:
我尝试使用 django smart select 链接材料和类别,但它不起作用
我的代码有什么问题?
class Demande_Expertise(models.Model):
user = models.ForeignKey(User)
material = models.ForeignKey("Material")
categorie = ChainedForeignKey("material.Category",
chained_field="material",
chained_model_field="name",
show_all=False,
auto_choose=True)
droits_acces = models.CharField(_('val_champ'), max_length=150, choices = DROITS)
groupe = models.ForeignKey(Group, blank = True, null= True, default = None)
etat = models.CharField(_('val_champ'), max_length=150, choices = ETAT, default = '2')
class Category(models.Model):
name = models.CharField(_('name'), max_length=50)
slug = models.SlugField()
class Material(models.Model):
name = models.CharField(_('name'), max_length=50)
description = models.TextField(_('description'), blank=True)
slug = models.SlugField()
category = ChainedForeignKey(Category, verbose_name=_('category'),
chained_field="name",
chained_model_field="name",
show_all=False,
auto_choose=True)
created = models.DateField(_("creation date"), auto_now_add=True)
【问题讨论】: