Join us on freenode.net channel #utah, the IRC channel for all LUGs in Utah. View channel stats.
redseam
Django MONTH_CHOICES
Have you ever wanted to give your model some month choices relating to integers 1-12. I would guess it’s pretty common – common enough to be included in django.contrib. Well, it is. Here is a quick tip on how to include it in a model:
from django.db import models from django.utils.dates import MONTHS class RevenueGoal(models.Model): month = models.PositiveSmallIntegerField(choices=MONTHS.items()) year = models.PositiveIntegerField() goal = models.DecimalField('Revenue Goal', max_digits=8, decimal_places=2)Related posts:
- Python, Django & the Google Adsense API I have been tasked with updating our real-time revenue stats...
- Django Textile/Markdown Template Caching Speedup I’ve been putting some time into updating an old site...
- Django Custom Upload Handler to Compress Image Files I got a somewhat unique request on a project the...
Related posts brought to you by Yet Another Related Posts Plugin.



:: Recent comments :.
1 year 14 weeks ago
1 year 33 weeks ago
2 years 39 weeks ago
2 years 43 weeks ago
3 years 3 weeks ago