Can't create many-to-many object in django admin using django-mptt -
I can not create an object in the Django admin, this error raises:
Value Error On / Admin / App / Category / Add / "& lt; Category: & gt;" Many-to-many relationships can be used from this before there should be value for the "to_category" field Request method: Request URL: http://127.0.0.1:8000/admin/app/category/ Add / Django version: 1.6.5 Exception type: valueAir exception value: "& lt; Category: & gt;" Many-to-many relationships can be used from this before there should be value for the "to_category" field exception space: /usr/local/lib/python2.7/dist-packages/django/db/models/ Fields / related.py __init__, line 524 python executable: / usr / bin / python Python Version: 2.7.6 I do not understand what is going wrong . Import the MDTT model from imported models from Mptt.models, tree MFTTafine class category (MPTT model): name = model.carfield (max_text = 255, default = u ''), engName = models.CharField (max_length = 255, default = U = ', blank = true) Parents = Vrikandhamandhamfild (' self ', symmetically = wrong, related_name =' children ', empty = true) Description = Model TextField (default = U' ', blank = True) Active = Model . Boolean field (default = true, empty = true) def __unicode __ (self): return U "{}". Format (self.name) class MPTTMeta: order_insertion_by = ['name'] parent_attr = 'parent'
and admin.py
APPmtmodladmin import from mptt.admin from django.contrib import admin. Models Import Category, Patterns admin.site.register (Category, MPTTModelAdmin) admin.site.register (Pattern)
with this problem tree managerfield parents. Ucture in a tree wire, nodes can only be a parent, so MPTT does not support this.
If you use TreeForeignKey , you should have a better fortune. I have added one about it. / P>
Comments
Post a Comment