python - Use a class before its definition in Django model -
when try syncdb error menu not valid class name.
how can resolve relationship case :
class menuitem(model.models) title = models.charfield(max_length=200) submenus = models.manytomanyfield(menu, blank=true, null=true) class menu(container): links = models.manytomanyfield(menuitem)
one of these models has many many, other 1 uses django's reverse relations (https://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward)
so how set up:
class menu(container): links = models.manytomanyfield(menuitem) class menuitem(model.models) title = models.charfield(max_length=200)
then when wanted menuitem's menus:
menu_item_instance.menu_set.all()
Comments
Post a Comment