python - django form won't populate decimal value with instance -


i have following form:

class searchdetailform(forms.modelform):     price_min = forms.decimalfield(max_digits=8, decimal_places=2, required=false)     price_max = forms.decimalfield(max_digits=8, decimal_places=2, required=false)     item = forms.modelchoicefield(queryset=item.objects.all(), required=false)     max_distance = forms.charfield(required=false)     sort = forms.choicefield(choices=sort_choices)      class meta:         model = buy         fields = (                   'item',                   'max_distance',                   'price_min',                   'price_max'                   ) 

the view implements form looks like:

def market_view(request):      max_distance = request.get.get('max_distance',none)     price_min_str = request.get.get('price_min',none)     price_max_str = request.get.get('price_max',none)     price_min = decimal(price_min_str)     price_max = decimal(price_max_str)     item = request.get.get('item',none)      buy = buy()     buy.price_min = decimal('10.10')     buy.price_max = decimal('10.10')     buy.item = item.objects.get(pk=item)      buy_items = buy.objects.filter(price__lte=price_max,price__gte=price_min).order_by('item')      form = searchdetailform(instance=buy)      context = {         'items':buy_items,         'form':form,      }      return render(request, 'index.html', context) 

i set form instance buy last searched values remain on page. item attribute remains, price_min , price_max not. can have them populate in form instance?


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -