JGAllen23 wrote: > I am building a website for a client and one of the pages they need is > an "about us" page which would just require 1 row of data. What is > the best way to handle this case where a model would only need 1 data > row?
Override the save() method for that model. E.g. class FeaturedProduct(models.Model): product = models.ForeignKey(Product) description = models.TextField(blank=True, null=True) class Admin: pass class Meta: verbose_name_plural = 'Featured Product on Home Page' def save(self): ''' There can only be one featured product and it goes on the home page. Forcing the id to 1 ensures that any attempt to create a new featured product will only modify the existing one. ''' self.id = 1 super(FeaturedProduct, self).save() def __str__(self): return self.product.name+' - '+self.product.product_numberx -- Regards, Clifford Ilkay Dinamis 1419-3266 Yonge St. Toronto, ON Canada M4N 3P6 <http://dinamis.com> +1 416-410-3326
smime.p7s
Description: S/MIME Cryptographic Signature