I have tabble where I am storing sitewide settings. So I want only
one row to be created in this table. I am trying to enforce this by
over riding the save method.
If I do something like
def save (self):
"""There should not be more than one Blog object"""
if Blog.objects.count() > 1:
raise "Only one blog object allowed."
super(Blog, self).save() # Call the "real" save() method.
I can get two rows, as when the second time save gets called, count is
only one.
If I do something like
def save (self):
"""There should not be more than one Blog object"""
if Blog.objects.count() >= 1:
raise "Only one blog object allowed."
super(Blog, self).save() # Call the "real" save() method.
Only one object is allowed, but updates wil fail. How can I enforce
single rows only?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---