Author's posts

Django url warning – / 제거?

django2.2 에서, 하나의 프로젝트에 여러개의 app을 들어서 app을 실행했을때 아래와같은 경고가 발생하는 경우, WARNINGS: ?: (urls.W002) Your URL pattern ‘/catsel/’ [name=’select’] has a route beginning with a ‘/’. Remove this slash as it is unnecessary. If this pattern is targeted in an include(), ensure the include() pattern has a trailing ‘/’. System check identified 1 …

Continue reading

Ubuntu 18.04, apache2에 http/2 설정하기.

Ubuntu 18.04, apache2에 http/2 설정하기. * 작업환경 OS:Ubuntu 18.04 Apache2 : 2.4.29 https: 사용중(Let’s encrypt 인증서) php: mod_php 7.2 별도 설정없이 apache2를 사용한다면 대부분 http/1.1을 사용하고 있을 것이다. 몇 가지 이유(약간의 속도향상, PUSH사용 등)로 http/2를 사용하고자 한다면 설정전 반드시 확인해야 할 사항이 있다. 1. apache2 버전: apache2는 http/2를 2.4.24 버전부터 지원하기 시작했다. 따라서, 버전을 확인해야한다. …

Continue reading

리눅스 HA(corosync, pacemaker, DRBD) – Part 2

corosync, pacemaker 클러스터에 DRBD 디스크 이용하기. 참고: 리눅스 HA(corosync, pacemaker) – Part 1 리눅스 HA (pacemaker, corosync, iscsi shared storage) – part 3 리눅스 HA(corosync, pacemaker, shared disk)에 zabbix 모니터링 서버 구성 – part 4 이 글은 리눅스 HA(corosync, pacemaker) – Part 1에 이어집니다. part2는 원래 iscsi 볼륨을 붙여서 active-active 클러스터로 넘어가는 글이었는데, 작성하다가 멈췄습니다.(여러가지 …

Continue reading

Cisco PBR(Poilcy Base Routing) 설정

Cisco PBR(Policy Base Routing) 설정 Source IP 주소를 확인하여 라우팅 경로를 다르게 설정하기 위해서 사용한다. SDM(Switch Databse Management) template이 필요하므로 설정을 확인하고 sdm template를 사용가능하도록 해야한다. SDM template 확인. number of IPv4 policy based routing aces 항목을 확인해 보면 0 이다. Switch#sh sdm prefer The current template is “aggregate default” template. The selected template optimizes …

Continue reading

[django 2.2] Get/Post를 동일한 템플릿에 표시하기.

Django class based view를 이용하여 동일한 페이지에 GET 과 POST를 모두 표시하는 방법. 1. View 작성(app/views.py) class GetPostView(View): template_name = ‘getpost.html’ data = [ {‘name’: ‘fox’, ‘title’: ‘test1’, ‘is_published’: True }, {‘name’: ‘wolf’, ‘title’: ‘test 2’, ‘is_published’: False}, {‘name’: ‘cat’, ‘title’: ‘life of cat’, ‘is_published’: True}, ] def get(self, request, *argc, **kwargs): context = { …

Continue reading

vmware cluster (6.0)에서 사용자 추가하고 역할 주기

vmware 6.0 클러스터 환경에서 사용자를 추가하기 위해서는 vsphere web client를 이용해야만 한다. vsphere client에서는 관련 메뉴가 보이지 않았다. 1. 웹브라우저를 실행하고, vcenter apppliance에 접속한다.

Continue reading

django2.2 url , url을 text로 유지하는 방법.

django 프로그램을 작성하다 보면, url에 내가원하는 텍스트를 붙여야 하는 경우가 생긴다. url은 주로 http://some.thing/view/123 이나 http://some.thing/view/wanted_text 이런 형식이 될 것이다. models.py가 아래와 같을때, from django.db import models # Create your models here. class TestData(models.Model): ip = models.GenericIPAddressField() mac = models.CharField(max_length=12, default=’000000000000′) date = models.DateTimeField(null=True) explane = models.CharField(max_length=64, null=True) 세 개의 view를 작성하고 각각의 템플릿을 작성한다.

Continue reading

django, ORM raw() vs connection

django를 사용하다보면, 복잡한 sql문을 django ORM으로 만들기가 매우 어려운 경우가 발생한다. 이럴 때, sql을 직접 이용하기 위해서 djanco connection을 사용할 수도 있지만, query 결과를 템플릿으로 전달하는데는 django queryset이 더 유리해 보인다. 1. app/models.py 에 아래와 같은 테이블을 만들고 migrate한다. from django.db import models # Create your models here. class TestData(models.Model): ip = models.GenericIPAddressField() mac = …

Continue reading

django-mptt 사용자 view

이전글 django-mptt로 tree 구조 만들기.에 이어 사용자에게 보여주는 페이지에서 tree구조를 보여주려면, view.py에 view 함수와 template을 만들어주어야한다. 먼저, view.py에 아래와 같이 view함수를 만들어준다. 아래처럼, Category 모델을 모두 불러와서 템플릿에 데이타를 보내는 뷰를 작성한다. from django.shortcuts import render # Create your views here. from django.views.generic import View from .models import Category class CategoryView(View): template_name = ‘tracer/category.html’ def …

Continue reading

django 데이타베이스 모델을 외부 스크립트에서 사용하는 방법

django2.4에서 만든 데이타베이스 모델을 외부 스크립트에서 사용하는 방법 작업환경: python3.7, django2.4 디렉토리 구조는 아래와 같다. 프로젝트 디렉토리 내에 util 디렉토리에 백엔드 스크립트를 위치시키고, 이 스크립트가 django 모델에 orm으로 엑세스 하기를 원할때의 설정 방법이다. sql을 직접 사용하는 방법도 있겠으나, 전체 프로젝트의 일관성을 위해 ORM을 사용하려면 아래와 같은 방법을 사용하면된다. d:\python_project\myproject\ ├─myproject │ └─settings.py ├─static │ └─bootstrap-4.3.1 …

Continue reading