python - Django, Initialize a field in child class from value in parent class -
in django,
say have 2 classes, , b.
b child of a. want there integer field in b pk of a. want field in b initialized such whenever create b object.
thanks.
p.s. want able access pk of parent object child class. if there easier/better way, please advise
you need set class foreign key class b
class b(models.model): = models.foreignkey(a) ...
new b = b.objects.create(a=instance_of_class_a, ...)
Comments
Post a Comment