python - django: TypeError: 'tuple' object is not callable -


getting type error, 'tuple' object not callable. idea be? (dont worry indentation. copies in weird.) i'm trying create choices based on packsize of storeliquor.

views.py:

def storeliquor(request, store_id, liquor_id):         = storeliquor.objects.get(storeliquorid=liquor_id) s = store.objects.get(storeid=store_id) x = order.objects.get(storeid=s, active=true) y = a.offpremiseprice c = a.bottlesize  g = request.post.get('orderamount', '') b = a.packsize h = b*2 d = b*3 e = b*4 r = b*5 if c == "1750 ml":     pack_size = (         ('1', '1')         ('3', '3')         (b, b)         (h, h)         (d, d)         (e, e)         (r, r)     ) elif c == "1000 ml":     pack_size = (         ('1', '1')         ('3', '3')         ('6', '6')         (b, b)         (h, h)         (d, d)         (e, e)         (r, r)     ) elif c == "750 ml":     pack_size = (         ('1', '1')         ('3', '3')         ('6', '6')         (b, b)         (h, h)         (c, d)         (e, e)         (r, r)     )      elif c == "375 ml":     pack_size = (         ('3', '3')         ('6', '6')         ('12', '12')         (b, b)         (h, h)         (d, d)         (e, e)         (r, r)     )         elif c == "200 ml":     pack_size = (         ('12', '24')         ('24', '24')         (b, b)         (c, c)         (c, d)         (e, e)         (r, r)     )  else:     pack_size = (         (b, b)         (c, c)         (c, d)         (e, e)         (r, r)     )             if request.method == "post":     f = addtoorderform(request.post)      if f.is_valid():         z = f.save(commit=false)         z.totalprice = (float(y)) * (float(g))         z.storeliquorid =         z.orderid = x          z.save()              return httpresponseredirect('/stores/get/%s' % store_id)  else:     f = addtoorderform()     f.fields['orderamount'].choices = pack_size       args = {}   args['liquor'] = args['s'] = s args['form'] = f     return render(request,'storeliquor.html', args) 

models file:

class liquororder(models.model):  liquororderid = models.autofield(primary_key=true) storeliquorid = models.foreignkey(storeliquor) orderid = models.foreignkey(order) orderamount = models.charfield('order amount', max_length=3) totalprice = models.decimalfield('total price', max_digits=5, decimal_places=2) storeprice = models.decimalfield('store price', max_digits=5, decimal_places=2) 

forms file:

class addtoorderform(forms.modelform):  class meta:     model = liquororder     fields = ('orderamount', 'storeprice') 

you're missing comma (,) inbetween:

>>> ((1,2) (2,3)) traceback (most recent call last):   file "<stdin>", line 1, in <module> typeerror: 'tuple' object not callable 

put comma:

>>> ((1,2), (2,3)) ((1, 2), (2, 3)) 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -