Automatically create and destroy child model instancesAutomatically create and destroy child model instances.
Automatically create child model instances when a parent class is created.
For example, given the following model definition:
from django.db import models from django_auto_one_to_one import AutoOneToOneModel class Parent(models.Model): field_a = models.IntegerField(default=1) class Child(AutoOneToOneModel(Parent)): field_b = models.IntegerField(default=2)
... creating a Parent instance automatically creates a related Child instance:
>>> p = Parent.objects.create() >>> p.child <Child: parent=assd> >>> p.child.field_b 2
A PerUserData helper is provided for the common case of creating instances when a User instance is created.
If you are looking for a highly experienced full-stack Django developer with a track record of producing high-quality and maintaininable code, please get in touch.