'전체 글'에 해당되는 글 11건

  1. 2020.08.25 Linux/SSH/MobaXterm 접속하기
  2. 2020.08.07 Django/Http 404 error 발생시키기
  3. 2020.07.13 Django/static files 경로 작성하기

MobaXterm을 통해 Ubuntu에 SSH 접속하는 방법을 노트

 

MobaXterm은 작성자가 기존 사용했던 Putty에 비해 더 다양하고 파워풀한 기능을 제공합니다.

 

MobaXterm 실행 화면

MobaXterm다운 받기

https://mobaxterm.mobatek.net/

 

MobaXterm free Xserver and tabbed SSH client for Windows

The ultimate toolbox for remote computing - includes X server, enhanced SSH client and much more!

mobaxterm.mobatek.net

무료 버젼인 Home edition을 설치 하도록 하자!

그리고 윈도우 Registry를 수정하는 Installer 버전보다는 zip 파일만 풀고 바로 실행하는 Portable 버전을 선호합니다.

작성자는 로컬 터미널에 접속하고 직접 ssh 명령어를 통해 접속하였습니다.

파란색 가린부분은 ip주소

ssh의 명령어

ssh -p[포트] [계정]@[ip주소] {명령어}

[대괄호]는 필수 입력이고 {중괄호}는 옵션입니다.

 

접속후 su - 명령을 통해 root로 접속합니다.

logout 명령으로 root를 빠져나옵니다.

한번더 logout을 하면 ssh 연결이 해제됩니다.

'Documents > 개발 노트' 카테고리의 다른 글

Ubuntu/nvidia-docker 설치  (0) 2020.08.31
Ubuntu/Nvidia version 확인  (2) 2020.08.31
Ubuntu/Docker 설치  (0) 2020.08.25
Django/Http 404 error 발생시키기  (0) 2020.08.07
Django/static files 경로 작성하기  (0) 2020.07.13
Posted by 치킨놈
:

개발 환경

OS : macOS Catalina

python ver : 3.7.8

django ver : 3.0.8

Terminal env.


view.py 템플릿에서 get_object_or_404를 import 합니다.

from django.shortcurs import render, get_object_or_404
from django.views.generic import View
from .models import Models

class Home(View):
	# ...
    det get(self, request, *args, **kwargs):
    	id = kwargs['slug']
        categories = get_object_or_404(Models, pk = id)
        context = {'categories': categories}
        
        return render(request, 'app/content1/html', context)

데이터베이스에서 request한 정보가 없을시 404에러를 return하는 라이브러리입니다.

 

 

다른방법으로는 

from django.http import Http404     # Http404를 import
from django.shortcuts import render

from .models import Question
# ...
def home(request, question_id):
    try:
        question = Question.objects.get(pk=question_id)  
        #check if question_id that user sends is valid
    except Question.DoesNotExist: # if not, send DoesNotExist
        raise Http404("Question does not exist") 
        #what specific message to show
    return render(request, 'app/detail.html', {'question': question})
    # write out the dictionary (variable is fine too)

try except 문을 이용하여 직접 404에러를 발생시킵니다.

이런 메서드는 if문이나 데이터베이스 문제가 아닌 다양한 에러에 대해서 적용 가능합니다.

'Documents > 개발 노트' 카테고리의 다른 글

Ubuntu/nvidia-docker 설치  (0) 2020.08.31
Ubuntu/Nvidia version 확인  (2) 2020.08.31
Ubuntu/Docker 설치  (0) 2020.08.25
Linux/SSH/MobaXterm 접속하기  (0) 2020.08.25
Django/static files 경로 작성하기  (0) 2020.07.13
Posted by 치킨놈
:

개발 환경

OS : macOS Catalina

python ver : 3.7.8

django ver : 3.0.8

Terminal env.


project/settings.py

STATICFILES_DIRS = (
	os.path.join(BASE_DIR, "static"),
	'/var/www/static',
)

static file(css,js,이미지,영상 등)을 한 폴더에 관리하기 위한 설정입니다.

static폴더에 없을시 '/var/www/static' 폴더에서 찾게 됩니다.

-

templates/base.html

{% load static %}
<!DOCTYPE html>

<html>
	<head>
		<meta name...>
		<link rel="stylesheet" href="{% static 'css/style.css' %}">
	</head>
    .
    .
    .

templates의 첫줄에 static을 불러오고

link할때 경로를 지정합니다.

-

'Documents > 개발 노트' 카테고리의 다른 글

Ubuntu/nvidia-docker 설치  (0) 2020.08.31
Ubuntu/Nvidia version 확인  (2) 2020.08.31
Ubuntu/Docker 설치  (0) 2020.08.25
Linux/SSH/MobaXterm 접속하기  (0) 2020.08.25
Django/Http 404 error 발생시키기  (0) 2020.08.07
Posted by 치킨놈
: