python - Django admin inline inside another inline -


i have 3 classes related each other fk. course grand parent, step parent, substep kid.

so each course has x steps , each step has x substeps.

when add new course want able add both steps , inside steps want able add substep. please see attached picture image

now won't show substep inline.

here models.py

class course(models.model):     created_at = models.datetimefield(auto_now_add=true)     title = models.charfield(max_length=255)     description = models.textfield()      def __str__(self):         return self.title  class step(models.model):     title = models.charfield(max_length=255)     description = models.textfield()     order = models.integerfield(default=0)     course = models.foreignkey(course)      def __str__(self):         return self.title  class substep(models.model):     title = models.charfield(max_length=255)     description = models.textfield()     order = models.integerfield(default=0)     step = models.foreignkey(step)      def __str__(self):         return self.title 

admin.py

from . models import course, step, substep  class stepinline(admin.stackedinline):     model = step  class courseadmin(admin.modeladmin):     inlines = [stepinline,]  class substepinline(admin.stackedinline):     model = substep  class stepadmin(admin.modeladmin):     inlines = [substepinline,]  admin.site.register(course, courseadmin) admin.site.register(step, stepadmin) admin.site.register(substep) 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -