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

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -