First, here's the problem I'm having, and then I'll bring up my
request. I have a model that looks like this (using dev version):
class SecretModel(models.Model):
some_unique_field = models.CharField(max_length=25, unique=True)
# Notice this is unique.
class MyModel(models.Model):
secret_model = models.OneToOneField(SecretModel, editable=False)
#
spam = models.CharField(max_length=15)
foo = models.IntegerField()
def clean(self):
SecretModel.objects.create(some_unique_field=self.spam)
Now if I go do this:
MyModel.objects.create(spam='john', foo='OOPS') # Obviously foo won't
take 'OOPS' as it's an IntegerField.
.... ERROR HERE
MyModel.objects.create(spam='john', foo=5) # So try again here.
... IntegrityError because SecretModel with some_unique_field = 'john'
already exists.
If there is a way to handle this behavior already, I apologize for
wasting your time. Otherwise, I'm suggesting the addition of
transaction handling for model methods. Is this reasonable?
--
You received this message because you are subscribed to the Google Groups
"Django developers" 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-developers?hl=en.