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

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -