On 19/08/2013 5:39pm, Victor Hooi wrote:
Hi,

I have a Django IntegerField that I'm using to store the purchase limit
for a product.

    purchase_limit = models.IntegerField()


I also need to represent no limit (i.e. infinity) as well in that field.

I was thinking of just using NULL to represent no limit.

    purchase_limit = models.IntegerField(blank=True, null=True)

If there is a purchase limit put it in. Otherwise there is no purchase limit. For me, None/Null would be comfortable. But I might be tempted to add functions in the model's clean() method which encapsulate the the business rules for the app - whatever they are.




Zero would have a meaning for this field (you can't buy any), however
negative numbers don't have any meaning.

Hence, another option is just to use say, -1 as the value to represent
no limit.

Any thoughts on either option, or which one is more "correct"?

Cheers,
Victor

--
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to