본문 바로가기

반응형

전체 글

(202)
Django 일부만 Test 하기 python manage.py test로 테스트 하면 App의 tests.py 파일내의 전체 test 소스가 test 된다. 이럴 땐 직접 method를 지정하여 Test를 실행 시키면 된다. python manage.py test blog.tests.TestView.test_post_list
Django TDD beautifulsoup4 사용하기 Django에는 화면 Test를 자동화 해주는 도구가 있다. pip install beautifulsoup4 이를 이용하면 화면을 브라우저로 실행해 보지 않아도 테스트가 가능하다.
Pillow Python에서 ImageField를 사용하기 Pillow는 Python에서 Image 처리를 하기 위해 사용되는 Library 입니다. 설치 방법 pip install Pillow
django TDD Test 실행 방법 python manage.py test django의 각 app에는 tests.py가 있고 거기에 Test Source를 작성하면 됩니다. class TestView(TestCase): def test_post_list(self): self.assertEqual(2, 3)​ 결과 2는 3이 아니므로 Test는 Fail이 됩니다. $ python manage.py test Found 1 test(s). Creating test database for alias 'default'... System check identified no issues (0 silenced). F =================================================================..
Django shell을 이용하여 source 실행 시키기 예제 1 $ python manage.py shell Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from blog.models import Post >>> p = Post.objects.last() >>> p.title '시간 자동 저장' >>> p.create_at datetime.datetime(2022, 2, 17, 12, 48, 24) >>> p.update_at datetime.datetime(2022..
Ajax 통신 시 Form 데이터 만들기 Document에 Form을 그대로 사용해서 FormData 만드는 방법 실제 form을 불러와서 설정할 수 있다. let file_form = document.getElementById("file_form"); var formdata = new FormData(file_form); oAjaxReq.send(formdata); Javascript에서 Form을 구성하는 방법 let formData = new FormData(); formData.append('post_id', post_id); formData.append('comment', comment); oAjaxReq.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); oAjaxReq.send(fo..
console log 남기기 브라우저 Debug 모드 사용 시 console에 log를 남길 수 있다. 방법은 console.log("남기고 싶은 메시지") 와 같이 사용하는 것이다. console.log(i);
Django view에서 넘기지 않은 key 값을 구분하기 if문과 None 키워드를 사용하여 서버에서 넘어오지 않은 값을 구분할 수 있다. {% if js_url != None %} {% endif %}

반응형