<https://lh3.googleusercontent.com/-CmnYqbBB-ws/VKjVXOH24II/AAAAAAAAHQw/0zYR1Des11Y/s1600/checkbox%2Boption.png>
I want to program to calculate sum of user sleclecion of options with 
checkbox.
Pls help me how to keep away from this suffer.
I summarize what I want to do in my attached ppt file.

How can I code for this in my viws.py & models.py each?


#Product&Choice Model - models.py

class Product(models.Model):
title = models.CharField(max_length=120)
description = models.TextField(null=True, blank=True)
price = models.DecimalField(decimal_places=0, max_digits=100, default=10000)

class Choice(models.Model):
product = models.ForeignKey(Product)
name = models.CharField(max_length=255)
price = models.DecimalField(decimal_places=0, max_digits=100, default=0)

# single.html

<p>Your Product Price : {{ product.price }}$</p><hr/>

{% for item in product.choice_set.all %}
<form method='POST' action=''>{% csrf_token %}<input type='checkbox' 
value='{{ item.id }}' name='choice'> {{ item.name }} : {{ item.price }}$ 
<br/>
{% endfor %}
<input type='submit' value='submit'>
</form><hr/>
~~

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/339afca5-ce00-4d5e-b117-ee2bc6560e01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: optioncheckbox.pptx
Description: MS-Powerpoint 2007 presentation

Reply via email to