2👍
Couldn’t you do something like this?
def save(self, *args, **kwargs):
if not self.belongs_to:
self.belongs_to = self.related_email.belongs_to
return super(Blog, self).save(*args, **kwargs)
-1👍
First, add null = True
to Blog.belongs_to
Assuming that you know the owner of the registration email, you can do
owner = User.objects.get(field = value)
email = Email.objects.get(belongs_to = owner)
Blog.objects.create(address = ..., related_email = email, belongs_to = None)
And then should you need to do any updates, you can do
blog = Blog.objects.filter(related_email = email).filter(belongs_to__isnull = True)
blog.belongs_to = newUserObject
- [Answer]-Add customize field in openerp 7, but no result
- [Answer]-Django custom form validation error
- [Answer]-General purpose Python functions in Django views.py
- [Answer]-Django South datamigration pre_save() uses model's __unicode__()
- [Answer]-/complete/email does not exist in python-social-auth
Source:stackexchange.com