开发者

django one-to-one relationship defaulting to existing object - is this what is supposed to happen?

开发者 https://www.devze.com 2023-04-07 10:51 出处:网络
I have three models, related with one-to-one relationships. So far as relevant, the code for them is:

I have three models, related with one-to-one relationships. So far as relevant, the code for them is:

class Member(models.Model):
    deferred_on = models.OneToOneField('PendingAuthorisation',
                                   related_name = 'defers_member',
                                   on_delete=models.SET_NULL,
                                   null=True,
                                   blank=True,
                                   default = None)

class Director(models.Model):
    deferred_on = models.OneToOneField('PendingAuthorisation',
                                   related_name = 'defers_director',
                                   on_delete=models.SET_NULL,
                                   null=True,
                        开发者_如何学运维           blank=True,
                                   default = None)

class PendingAuthorisation(models.Model):
    ...

My issue is that when I create a new PendingAuthorisation, it's defers_member and defers_director properties default to an existing Member or Director even if those objects do not have a deferred_on property set.

Is this supposed to happen? Is there any way to stop this happening? Is this a bug in django?

edit: I'm using django 1.3 (not 1.3.1).

0

精彩评论

暂无评论...
验证码 换一张
取 消