def handle(self, *args, **options): print('Start loading...') Page.objects.all().delete() Slider.objects.all().delete() Gallery.objects.all().delete() # главная path = os.path.join(BASE_DIR, '..', 'data', 'index.txt') with open(path, 'r') as f: txt = f.read() print(txt) p = Page() p.title = 'О нас' p.content = txt p.alias = 'home' p.save() # расписание path = os.path.join(BASE_DIR, '..', 'data', 'schedule.txt') with open(path, 'r') as f: txt = f.read() print(txt) p = Page() p.title = 'Расписание' p.content = txt p.alias = 'schedule' p.save() # импорт картинок слайдера for i in range(1, 5): img = '%s.jpg' % i img_abspath = os.path.join(BASE_DIR, '..', 'data', img) print('Importing... %s' % img_abspath) s = Slider() s.title = img s.desc = 'Description of %s' % img s.save() with open(img_abspath, 'rb') as doc_file: s.image.save(img, File(doc_file), save=True) # импорт галереи for i in range(1, 22): img = '%s.jpg' % i img_abspath = os.path.join(BASE_DIR, '..', 'data', 'gallery', img) g = Gallery() g.title = img g.save() with open(img_abspath, 'rb') as doc_file: g.image.save(img, File(doc_file), save=True)
def handle(self, *args, **kwargs): print('Loading data into database....') try: p = Page.objects.get(name_slug='index') except: p = Page() p.name_slug = 'index' p.title = 'Welcome to the WEZOM support desktop!' p.content = 'You can send your message here.' p.save() print('Creating main page!') try: u = User.objects.get(username='******') except: u = User() u.username = '******' u.is_active = True u.is_superuser = True u.is_staff = True u.save() u.set_password('admin') u.save() print('Creating superuser login admin password admin.') load_cat()
def handle(self, *args, **options): print('loading pages....') Page.objects.all().delete() p = Page() p.title = "Main page" p.alias = "main" p.content = "Content" p.save() p = Page() p.title = "Contact page" p.content = "Content" p.alias = "contact" p.save() p = Page() p.title = "Shop page" p.alias = "shop" p.content = "Content" p.save()
def handle(self, *args, **options): print 'Start' Page.objects.all().delete() p = Page() p.title = 'логин admin пароль 123' p.content = 'Conteentttt ttttt t tt ' p.alias = 'main' p.meta_keywords = 'main' p.meta_description = 'main' p.meta_title = 'main' p.save() print 'Page main was created'
def save_page(request): title = request.REQUEST["title"] url = request.REQUEST["url"] keywords = request.REQUEST["keywords"] desc = request.REQUEST["desc"] content = request.REQUEST["content"] template = request.REQUEST["template"] id = request.REQUEST["id"] page = Page() if id == "-1" else Page.objects.get(pk=int(id)) logging.info("save") if page: page.title = title page.url = url page.keywords = keywords page.desc = desc page.content = content page.template = template page.save() return HttpResponse("{}")