django smart_selects - ошибка syncdb - PullRequest
       1

django smart_selects - ошибка syncdb

2 голосов
/ 05 февраля 2012

получаю ошибку:

TypeError: init () получил неожиданный аргумент ключевого слова 'chained_model_field'

во время работы syncdb после смены модели.

model.py

class Category(models.Model):
    cat_no = models.IntegerField(null=True, blank=True)
    cat_txt = models.CharField(max_length=45)

class E_cat(models.Model):
    cat_no = models.ForeignKey(Category)
    cat_txt = models.CharField(max_length=45)
    scat_no = models.IntegerField(null=True, blank=True)
    scat_txt = models.CharField(max_length=45)

class Equip(models.Model):
    category = models.ForeignKey(Category)
    subcategory = models.ForeignKey(
        E_cat,
        chained_field="cat_no",
        chained_model_field="cat_no",
        show_all=False,
        auto_choose=True,
    )
    manufacturer = models.CharField(max_length=35, blank=True)
    mfg_no = models.CharField(max_length=35, blank=True)
    size = models.CharField(max_length=35, blank=True)
    color = models.CharField(max_length=35, blank=True)
    quanity = models.IntegerField(null=True, blank=True)
    short_description = models.CharField(max_length=80, blank=True)
    location_zip = models.IntegerField(null=True, blank=True)
    listings = models.ForeignKey(Listings)
    info = models.TextField(null=True, blank=True)

1 Ответ

0 голосов
/ 05 февраля 2012

Проблема в том, что django.db.models.ForeignKeyField не принимает аргумент chained_model_field.

Вы можете увидеть это в трассировке, которую вы получили бы:

  File ".../models.py", line 42, in MyModel
    subcategory = m.ForeignKey(…)               <--- here
  File "…/related.py", line 840, in __init__
    Field.__init__(self, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'chained_model_field'

Возможно, вы хотите https://github.com/digi604/django-smart-selects, который определяет ForeignKey -подобное поле, которое включает chained_model_field аргумент?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...