Django: Database Model For Prize Structure
<p>I'm trying to figure out the proper way to go about structuring a model for a contest's payout/prize structure, an example is below</p>

<p>1st: $50000
2nd: $10000
3rd-10th: $1000
10th-70th: $500
70th-150th: $25
150th-400th: $1</p>

<p>My first thought was to design it like this:</p>

<pre><code>class Prize(models.Model):
    place=models.IntegerField()
    prize=models.IntegerField()
</code></pre>

<p>The issue for me is that once you get to the lower tier, you begin having multiple entries that are repetitive.  So from 150th-400th I would have 250 of the same entries.  I'm wondering if there is a smarter way to go about this.  Thanks.</p>

<p>First of all, never use integers to store prices. Always try to use decimal field. If you have never tried it, there is a thing to notice. You have to supply max_digits and decimal_places. For example:</p>

<pre><code>prize = forms.DecimalField(max_digits=10, decimal_places=2)
</code></pre>

<p>So you can only use 8 digits (not 10) with 2 decimal places.</p>

<p>In order to answer your question. Add <strong>from range</strong> and <strong>to range</strong>.
Then also in meta add unique_together, so you will not have duplicates for  the same ranges with the same prize.</p>

python django django-models