问题
I installed (pip) django-categories today, and added a field in my model:
categories = models.ManyToManyField('categories.Category', blank=True, null=True)
before running syncdb
.
I have Categories in my admin, and I'm not seeing any file errors for treeTable or expand/collapse files, but I'm only seeing 1 level deep:

In the source for the page, I can see the child rows, but they don't show in the admin. Nor does a expand/collapse toggle.
The following doesn't seem to be true, either. I'm using fieldsets, and the categories field only shows up if I include it in the fieldsets in my ModelAdmin.
https://django-categories.readthedocs.org/en/latest/admin_settings.html
I'm using Django 1.6.
Should I be seeing something else in the admin? How do I enable the treeview + checkboxes described in the docs?
Thanks!
Mark
UPDATE: This seems to be a JavaScript issue. I can see the treeTable.js function running on each TR. I can force it to initialize the table in expanded mode and see the child rows. But it never sets up the expand/collapse functionality. Still an issue, but now it's a JS issue.
I've been updating an issue on the github repository for django-categories: https://github.com/callowayproject/django-categories/issues/79
回答1:
This was unrelated to anything within django-categories, though it's worth pointing out that Django 1.6 is bundling jQuery 1.9.1 and jQuery.treeTable bundled with django-categories is from 2010. There's much newer code available.
The child rows and expand collapse functionality were getting loaded. They simply weren't visible in the Django Admin. I removed the negative margin from line 426 in jquery.treeTable.js
. From there I modified jquery.treeTable.css
as well to tighten up the UI a bit. I ended up further customizing jquery.treeTable.js
to indent the category names in the change list rather than the checkboxes.
I copied both files to project/categories/editor/static/editor
to override the defaults.
来源:https://stackoverflow.com/questions/20051740/django-categories-admin-not-working-as-expected