python - FieldError at /autocomplete/ItemsAutocomplete/ -
i using autocomplete_light in django model form.
this model form
class ca_dispensaries_item(timestampedmodel): item = models.foreignkey(items) dispensary = models.foreignkey(ca_dispensaries) description = models.charfield(max_length=5000, null=true)
this form
class camenuform(autocomplete_light.modelform): class meta: model = ca_dispensaries_item exclude = ('dispensary',) autocomplete_fields = ('item',)
registered as
autocomplete_light.register(items, search_fields=('item_name'))
when try enter values in item
, per autocomplete feature, starts searching gives field error
cannot resolve keyword u'i' field. choices are: arizona_dispensaries_item, ca_dispensaries_item, colorado_dispensaries_item, created, id
dont know i
coming from. also, dispensaries_items of models. while created
, id
field names
you have forgottent comma! change
search_fields=('item_name')
to
search_fields=('item_name',)
search_fields
should iterable, if has value ('item_name')
(which string) 'i', 't', 'e', etc (that's why message cannot resolve keyword u'i' field
)
also, there serious problems names models: see have model named items
, model named ca_dispensaries_item
. should not name models in plural, items
should item
, need use camelcase class names, ca_dispensaries_item
should cadispensariesitem``.
Comments
Post a Comment