def create_main_tree(sender, **kwargs): Tree = get_tree_model() TreeItem = get_tree_item_model() main, c = Tree.objects.get_or_create(title='Menu principal', alias='main') TreeItem.objects.get_or_create(title='Início', url='home', alias='home', urlaspattern=True, inmenu=True, insitetree=True, tree=main)
from django.core import serializers from django.core.management.base import BaseCommand, CommandError from django.db import DEFAULT_DB_ALIAS from sitetree.utils import get_tree_model, get_tree_item_model from sitetree.compat import CommandOption, options_getter MODEL_TREE_CLASS = get_tree_model() MODEL_TREE_ITEM_CLASS = get_tree_item_model() get_options = options_getter(( CommandOption( '--indent', default=None, dest='indent', type=int, help='Specifies the indent level to use when pretty-printing output.'), CommandOption('--items_only', action='store_true', dest='items_only', default=False, help='Export tree items only.'), CommandOption('--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, help='Nominates a specific database to export fixtures from. Defaults to the "default" database.'), )) class Command(BaseCommand): option_list = get_options() help = 'Output sitetrees from database as a fixture in JSON format.' args = '[tree_alias tree_alias ...]'
from optparse import make_option from django.core import serializers from django.core.management.base import BaseCommand, CommandError from django.db import DEFAULT_DB_ALIAS from sitetree.utils import get_tree_model, get_tree_item_model MODEL_TREE_CLASS = get_tree_model() MODEL_TREE_ITEM_CLASS = get_tree_item_model() class Command(BaseCommand): option_list = BaseCommand.option_list + ( make_option( '--indent', default=None, dest='indent', type='int', help= 'Specifies the indent level to use when pretty-printing output.'), make_option('--items_only', action='store_true', dest='items_only', default=False, help='Export tree items only.'), make_option( '--database', action='store', dest='database',