add extra tickboxes for use with action dropdown
I want to use the django admin app to connect two records (as a parent and child).
Using the admin actions guide here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/ I have wrote a function which almost does this by utilises the actions dropdown (on the list view). What I have is the user ticks two records and then selects make connection from the dropdown which triggers my custom function to make the connection between the two (setting the foreignkey of one record to be the other).
However since it is a parent and child relationship the order is important so what I'd like is 2 rows of tickboxes one saying parent and the other saying child. The user would then tick one in each row then then running the function.
So what I'd like to know is what is the best way to do this using the django admin?
Wouldn't it be better to have a ForeignKey field that links to the same model (loopback relationship) where you can select your parent entry?
class MyRecord(models.Model):
parent = models.ForeignKey(MyRecord)
....
Then there's django-mptt
链接地址: http://www.djcxy.com/p/65418.html上一篇: Django Admin根据类的类型更改内联管理员表单
下一篇: 添加额外的复选框以用于操作下拉菜单