Django query for a select item return ‘———‘

  Kiến thức lập trình

I’m trying to populate a select item with a django queryset.
It’s working fine but at the begining of the list of the dropdown menu on the select item I always have a ‘———‘ as first option.

forms.py

class forms_bdc(forms.ModelForm):
[...]
    bdc_description_1 = forms.ModelChoiceField(queryset=models_products.objects.values_list('product_denomination', flat=True),required=False, widget=forms.Select(attrs={'id': 'editable-select-2'}))

The “product_denomination” on the database only contains 2 lines but I always have this ‘———‘ on first option.

What am I missing ?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT