inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

172만명의 커뮤니티!! 함께 토론해봐요.

test중 오류가 나오는데 해답을 찾지못하겠습니다 ㅠㅠ

미해결

파이썬 사용자를 위한 웹개발 입문 A to Z Django + Bootstrap

이제 막 공부를 시작한터라 몇일째 혼자 해결해볼려고 해도 도저히 모르겠습니다... 전 강의 tag페이지 만들기에선 아무런 문제가없었는데 post detail개선 부분부터 오류가 나옵니다. 이 오류를 무시하고 그대로 진도를 나가도 블로그 나 어드민 페이지에선 아무런 문제가 발생하진않지만 어느부분이 잘못되어서 오류가 나오는지 가르쳐주세요!ㅠㅠ post_detail {% extends 'blog/base.html' %} {% block content %} <h1 id="blog-list-title"> Blog {% if category %}<small class="text-muted">: {{ category }}</small>{% endif %} {% if tag %}<small class="text-muted">: #{{ tag }}</small>{% endif %} </h1> {% if object_list.exists %} {% for p in object_list %} <!-- Blog Post --> <div class="card mb-4" id="post-card-{{ p.pk }}"> {% if p.head_image %} <img class="card-img-top" src="{{ p.head_image.url }}" alt="Card image cap"> {% else %} <img class="card-img-top" src="https://picsum.photos/750/300/?random" alt="Card image cap"> {% endif %} <div class="card-body"> {% if p.category %} <span class="badge badge-primary float-right">{{ p.category }}</span> {% else %} <span class="badge badge-primary float-right">미분류</span> {% endif %} <h2 class="card-title">{{ p.title }}</h2> <p class="card-text">{{ p.content | truncatewords:50 }}</p> {% for tag in p.tags.all %} <a href="{{ tag.get_absolute_url }}">#{{ tag }}</a> {% endfor %} <br/> <br/> <a href="{{ p.get_absolute_url }}" class="btn btn-primary" id="read-more-post-{{ p.pk }}">Read More &rarr;</a> </div> <div class="card-footer text-muted"> Posted on {{ p.create }} by <a href="#">{{ p.authro }}</a> </div> </div> {% endfor %} {% else %} <h3>아직 게시물이 없습니다.</h3> {% endif %} {% endblock %} test.py from django.test import TestCase, Client from bs4 import BeautifulSoup from .models import Post, Category, Tag from django.utils import timezone from django.contrib.auth.models import User def create_category(name='life', description=''): category, is_created = Category.objects.get_or_create( name=name, description=description ) category.slug = category.name.replace(' ', '-').replace('/', '') category.save() return category def create_tag(name='some tag'): tag, is_created = Tag.objects.get_or_create( name=name ) tag.slug = tag.name.replace(' ', '-').replace('/', '') tag.save() return tag def create_post(title, content, author, category=None): blog_post = Post.objects.create( title=title, content=content, created=timezone.now(), author=author, category=category, ) return blog_post class TestModel(TestCase): def setUp(self): self.client = Client() self.author_000 = User.objects.create(username='smith', password='nopassword') def test_category(self): category = create_category() def test_post(self): category = create_category() post_000 = create_post( title='The first post', content='Hello World. We are the world', author=self.author_000, category=category, ) self.assertEqual(category.post_set.count(), 1) def test_tag(self): tag_000 = create_tag(name='project') # bad_guy tag_001 = create_tag(name='portfolio') # america post_000 = create_post( title='The first post', content='Hello World. We are the world', author=self.author_000, ) post_000.tags.add(tag_000) post_000.tags.add(tag_001) post_000.save() post_001 = create_post( title='Stay Fool, Stay Hungry', content='Story about Steve jobs', author=self.author_000 ) post_001.tags.add(tag_001) post_001.save() self.assertEqual(post_000.tags.count(), 2) # post 는 여러개의 tag를 가질수잇다 self.assertEqual(tag_001.post_set.count(), 2) # 하나의 Tag는 여러개의 post에 붙을수있다 self.assertEqual(tag_001.post_set.first(), post_000) # 하나의 Tag는 자신을 가진 post들을 불러올수있다 self.assertEqual(tag_001.post_set.last(), post_001) # 하나의 Tag는 자신을 가진 post들을 불러올수있다 def test_post(self): category = create_category() post_000 = create_post( title='The first post', content='Hello World. We are the world', author=self.author_000, category=category, ) class TestView(TestCase): def setUp(self): self.client = Client() self.author_000 = User.objects.create(username='smith', password='nopassword') def check_navbar(self, soup): navbar = soup.find('div', id='navbar') self.assertIn('Blog', navbar.text) self.assertIn('About me', navbar.text) def check_right_side(self, soup): category_card = soup.find('div', id='category-card') self.assertIn('미분류 (1)', category_card.text) self.assertIn('정치/사회 (1)', category_card.text) def test_post_list_no_post(self): response = self.client.get('/blog/') self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') title = soup.title self.assertIn(title.text, 'Blog') self.check_navbar(soup) self.assertEqual(Post.objects.count(), 0) self.assertIn('아직 게시물이 없습니다', soup.body.text) def test_post_list_with_post(self): tag_portfolio = create_tag(name='portfolio') post_000 = create_post( title='The first post', content='Hello World. We are the world', author=self.author_000, ) post_000.tags.add(tag_portfolio) post_000.save() post_001 = create_post( title='The second post', content='Second Second Second', author=self.author_000, category=create_category(name='정치/사회') ) post_001.tags.add(tag_portfolio) post_001.save() self.assertGreater(Post.objects.count(), 0) response = self.client.get('/blog/') self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') body = soup.body self.assertNotIn('아직 게시물이 없습니다', body.text) self.assertIn(post_000.title, body.text) post_000_read_more_btn = body.find('a', id='read-more-post-{}'.format(post_000.pk)) self.assertEqual(post_000_read_more_btn['href'], post_000.get_absolute_url()) self.check_right_side(soup) # main_div에는 main_div = soup.find('div', id='main-div') self.assertIn('정치/사회', main_div.text) ### '정치/사회' self.assertIn('미분류', main_div.text) ### '미분류' # Tag post_card_000 = main_div.find('div', id='post-card-{}'.format(post_000.pk)) self.assertIn('#portfolio', post_card_000.text) # Tag 가 해당 post의 card 마다 있다. def test_post_detail(self): category_politics = create_category(name='정치/사회') post_000 = create_post( title='The first post', content='Hello World. We are the world', author=self.author_000, category=category_politics ) tag_portfolio = create_tag(name='portfolio') post_000.tags.add(tag_portfolio) post_000.save() post_001 = create_post( title='The second post', content='Second Second Second', author=self.author_000, category=create_category(name='정치/사회') ) self.assertGreater(Post.objects.count(), 0) post_000_url = post_000.get_absolute_url() self.assertEqual(post_000_url, '/blog/{}/'.format(post_000.pk)) response = self.client.get(post_000_url) self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') title = soup.title self.assertEqual(title.text, '{} - Blog'.format(post_000.title)) self.check_navbar(soup) body = soup.body main_div = body.find('div', id='main-div') self.assertIn(post_000.title, main_div.text) self.assertIn(post_000.author.username, main_div.text) self.assertIn(post_000.content, main_div.text) self.check_right_side(soup) # Tag self.assertIn('#portfolio', main_div.text) self.assertIn(category_politics.name, main_div.text)# 카테고리가 main_div 에 있다. self.assertNotIn('EDIT', main_div.text)# 에디트 버튼이 로그인하지 않은유저에겐 보이지않는다 login_success = self.client.login(username='smith', password='nopassword')# 로그인을 한 경우에는 self.assertTrue(login_success) response = self.client.get(post_000_url) self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') main_div = soup.find('div', id='main-div') self.assertEqual(post_000.author, self.author_000)# post.author 와 login 한 사용자가 동일하면 self.assertIn('EDIT', main_div)# EDIT 버튼이 있다. # 다른 사람인 경우에는 없다. def test_post_list_by_category(self): category_politics = create_category(name='정치/사회') post_000 = create_post( title='The first post', content='Hello World. We are the world', author=self.author_000, ) post_001 = create_post( title='The second post', content='Second Second Second', author=self.author_000, category=category_politics ) response = self.client.get('/blog/category/_none/') self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') # self.assertEqual('Blog - {}'.format(category_politics.name), soup.title.text) main_div = soup.find('div', id='main-div') self.assertIn('미분류', main_div.text) self.assertNotIn(category_politics.name, main_div.text) def test_teg_page(self): tag_000 = create_tag(name='project') # bad_guy tag_001 = create_tag(name='portfolio') # america post_000 = create_post( title='The first post', content='Hello World. We are the world', author=self.author_000, ) post_000.tags.add(tag_000) post_000.tags.add(tag_001) post_000.save() post_001 = create_post( title='Stay Fool, Stay Hungry', content='Story about Steve jobs', author=self.author_000 ) post_001.tags.add(tag_001) post_001.save() response = self.client.get(tag_000.get_absolute_url()) self.assertEqual(response.status_code, 200) soup = BeautifulSoup(response.content, 'html.parser') main_div = soup.find('div', id='main-div') blog_h1 = main_div.find('h1', id='blog-list-title') self.assertIn('#{}'.format(tag_000.name), blog_h1.text) self.assertIn(post_000.title, main_div.text) self.assertNotIn(post_001.title, main_div.text)

  • bootstrap
  • django
  • python
qwer993 댓글 2 좋아요 0 조회수 333

독학으로 공부해보고 싶어서 오늘 등록했는데요!

미해결

인터랙티브 웹 개발 제대로 시작하기

어떤식으로 공부를 하는게 좋을지 궁금해서 질문드립니다.. 인터넷 강의는 처음이라 한번 눈으로 쭉보고 그다음에 따라하는게 좋을지;; 아니면 첨부터 같이 코딩하면서 따라하는게 좋을지 고민되요 ㅠㅠ; 제가 프로그램은 처음이라 어떤식으로 공부해야할지 그게 제일 고민이 되네요;; 열심히 하다보면 잘할수 있겠죠? ㅠㅠ 이 강의를 끝내고 다음 강의도 있던데 그것도 들어볼려구요! 아무튼 스타트 합니다.!

  • HTML/CSS
  • 인터랙티브-웹
  • javascript
김동 댓글 1 좋아요 0 조회수 167

섹션 5 3번 후위표기식

미해결

파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)

import sys a=input() stack=[] # stack.top의 우선순위가 자기보다 크지 않을 때 pop res="" for x in a: if x.isdecimal(): res+=x else: # 문자일 경우 if x=='(': # 일단 append stack.append(x) elif x=='*' or x=='/' or x=='+' or x=='-': while stack and (stack[-1]=='*' or stack[-1]=='/'): # stack.top의 우선순위가 작지 않을 때 pop res+=stack.pop() stack.append(x) elif x==')': while stack and stack[-1]!='(': # 괄호 안의 연산자 res+=stack.pop() stack.pop() while stack: res+=stack.pop() print(res) 선생님이 말씀하신 대로 코드를 짰는데 검사를 했을 때 앞에 두개 빼고는3~5번은 wrong answer 라고 나오네요. 제가 in3을 입력으로 넣어서 출력한 후위표기식을, 다시 중위표기식으로 바꿨을때와(손으로 직접), out3의 후위표기식을 중위표기식으로 바꿨을 때(손으로 직접) 결과가, in3으로 동일합니다. 동일한 중위표기식에 대한 후위표기식이 1개 이상이 아닐까요? 제가 틀렸다면 어떤 부분이 문제인지 지적 부탁드립니다

  • python
  • 코테 준비 같이 해요!
dasomjang33 댓글 1 좋아요 0 조회수 137

안녕하세요~^^

미해결

[개정판] 딥러닝 컴퓨터 비전 완벽 가이드

안녕하세요~!^^ 혹시 coco dataset과 kitti dataset을 합쳐서 딥러닝시켜 object detection 시킬 수 있을까요? 있다면 어떻게 할 수 있을까요? 강의와 관련있는 질문 을 남겨주세요. &bull; 강의와 관련이 없는 질문은 지식공유자가 답변하지 않을 수 있습니다. (사적 상담, 컨설팅, 과제 풀이 등) &bull; 질문을 남기기 전, 비슷한 내용을 질문한 수강생이 있는지 먼저 검색 을 해주세요. (중복 질문을 자제해주세요.) &bull; 서비스 운영 관련 질문은 인프런 우측 하단 &lsquo;문의하기&rsquo; 를 이용해주세요. (영상 재생 문제, 사이트 버그, 강의 환불 등) 질문 전달 에도 요령이 필요합니다. &bull; 지식공유자가 질문을 좀 더 쉽게 확인할 수 있게 도와주세요. &bull; 강의실 페이지 (/lecture) 에서 '질문하기'를 이용해주시면 질문과 연관된 수업 영상 제목이 함께 등록됩니다. &bull; 강의 대시보드에서 질문을 남길 경우, 관련 섹션 및 수업 제목을 기재 해주세요. &bull; 수업 특정 구간에 대한 질문은 꼭 영상 타임코드 를 남겨주세요! 구체적인 질문 일수록 명확한 답을 받을 수 있어요. &bull; 질문 제목은 핵심 키워드를 포함해 간결하게 적어주세요. &bull; 질문 내용은 자세하게 적어주시되, 지식공유자가 답변할 수 있도록 구체적으로 남겨주세요 . &bull; 정확한 질문 내용과 함께 코드 를 적어주시거나, 캡쳐 이미지 를 첨부하면 더욱 좋습니다. 기본적인 예의 를 지켜주세요. &bull; 정중한 의견 및 문의 제시, 감사 인사 등의 커뮤니케이션은 더 나은 강의를 위한 기틀이 됩니다. &bull; 질문이 있을 때에는 강의를 만든 지식공유자에 대한 기본적인 예의를 꼭 지켜주세요. &bull; 반말, 욕설, 과격한 표현 등 지식공유자를 불쾌하게 할 수 있는 내용 은 스팸 처리 등 제재를 가할 수 있습니다.

  • python
  • 컴퓨터-비전
  • 머신러닝 배워볼래요?
  • 딥러닝
  • tensorflow
  • keras
김희선 댓글 7 좋아요 0 조회수 770

bad practices 질문

미해결

홍정모의 따라하며 배우는 C언어

강의 중 19:00의 bad practices 예제에 대해 질문 드립니다. #include <stdio.h> int main(void) { int n = 1; printf("%d, %d\n", n, n * n++); return 0; } 를 컴파일하니 2, 2가 출력되는데 왜 그런 것인가요?? 1, 1아닌가요??

  • c
yezi2792 댓글 1 좋아요 0 조회수 194

자료는 어떻게 받을 수 있나요?

미해결

[리뉴얼] 파이썬입문과 크롤링기초 부트캠프 [파이썬, 웹, 데이터 이해 기본까지] (업데이트)

안녕하세요! 이제 막 강의에 입문한 늦깎이입니다. 강의 안내에 자료를 주신다고 안내되어 있는데 어떻게 받을 수 있나요^^

  • python
  • 웹-크롤링
노현욱 댓글 1 좋아요 0 조회수 612

3-20 querySelector질문

미해결

프로그래밍 시작하기 : 웹 입문 (Inflearn Original)

var accountInput = document.querySelector('input[name="account"]'); 여기서 괄호 안에 'input[name="account"]' 이거는 무슨 선택자인가요??

  • javascript
  • HTML/CSS
은냥 댓글 1 좋아요 0 조회수 177

주석처리

미해결

인터랙티브 웹 개발 제대로 시작하기

강사님 아톰에서 /* */ 주석처리 하시는거 단축키 이용하시는거 같은데 무슨 키로 주석처리 하신건가요? 윈도우는 안되는건가요?

  • 인터랙티브-웹
  • HTML/CSS
  • javascript
이동진 댓글 1 좋아요 0 조회수 218

네이버 클라우드 플랫폼 유료인데요??

미해결

코로나맵 개발자와 함께하는 지도서비스 만들기 1

안녕하세요 어제 시작했는데요 네이버 클라우드 플랫폼 유료인데요??

  • 웹앱
  • vscode
  • nodejs
  • express
임권일 댓글 4 좋아요 1 조회수 263

구조체 포인터 관련 질문입니다!

해결됨

리눅스 시스템 프로그래밍 - 이론과 실습

14:28분경 P라는 구조체의 포인터에 맴버 접근시 왜 dote( . )연산을 사용하는것 이죠? 포인터의경우 -> 연산자를 사용해서 접근해야하는것 아닌가요??

  • linux
zbqmgldjfh 댓글 2 좋아요 1 조회수 272

굳이 컨트롤러에 MemberForm

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

굳이 컨트롤러에 MemberForm을 만들 이유가 있나요? 그냥 MemberController에서 아래처럼 멤버를 바로 받아올 수는 없는건가요? 만약에 멤버폼을 반드시 이용해야하는 것이라면 MemberForm이라는 클래스는 어떠한 어노테이션도 없이 순수 자바코드인데 어떻게 폼에서 name값을 받아와 setName을 해주는지 궁금합니다. public String create (Member newMember){ memberService.join(newMember); return "redirect:/"; }

  • spring-boot
  • spring
  • MVC
  • java
Rapture 댓글 4 좋아요 22 조회수 967

예약을 기다린다.

미해결

[C#과 유니티로 만드는 MMORPG 게임 개발 시리즈] Part4: 게임 서버

bool pending = _socket.ReceiveAsync(recvArgs); if(pending == false) //false 가 되는 것이 예약을 기다린것이다? { OnRecvCompeleted(null, recvArgs); } pending 을 통해서 예약 컬백을 때렸는지 않때렸는지 판단하는 건가요? 제가 잘못 이해한것 이 아닌가 싶어서 그렇습니다.

  • unity
  • network
  • C#
따뜻한눈빛 댓글 1 좋아요 0 조회수 225

Theorem 7 제약조건

미해결

선형대수학개론

안녕하세요 ! 이해가 안가는 부분이 있어서 질문드립니다. 24분 55초에서 y가 왜 u1와 orthogonal한가요 ? y가 (0, 1, 0)일때 x = u2라서 u2와 u1가 orthogonal해서 제약조건 만족한단 식으로 이해했는데 왜 갑자기 y와 u1이 orthogonal 한건지, 제가 어떤 부분을 놓쳤는지 모르겠습니다ㅜㅜ y와 u1 닷 프러덕트 하면 u2의 두번째 엔트리가 나와야하는거 아닌가요 ??

  • 선형대수학
chat 댓글 2 좋아요 0 조회수 222

안녕하세요 리브온 크롤링 하려고 F12 눌러보면

해결됨

남박사의 파이썬 기초부터 실전 100% 활용

https://onland.kbstar.com/quics?page=okbland 크롤링하려고 F12 누르면 다시 닫힙니다 방법이 없나요? 감사합니다

  • 웹-크롤링
  • python
major 댓글 2 좋아요 1 조회수 389

LED불이 안들어와요

해결됨

MQTT 사물인터넷 통신 프로젝트 (Arduino, MQTT, Node.js, mongoDB, Android)

127.0.0.1:3000/MQTT.html 싸이트에서 온오프 누르면 cmd창에 1 2 는 뜨는데 led에 불이 안들어와요. 어디서 잘못된것인지 알수있을까요?

  • iot
  • mongodb
  • arduino
  • nodejs
high18235 댓글 7 좋아요 0 조회수 745

scrapy shell에서 실행이 너무 복잡하게 보입니다

미해결

현존 최강 크롤링 기술: Scrapy와 Selenium 정복

scrapy shell로 css 값을 확인할려고 하면 이렇게 다 붙어져서 나옵니다.(오류는 없습니다) 동영상에 나오듯 하나씩 띄어쓰게 나오게 하는 방법은 없나요?? 확인할려고 하면 너무 꼬여서 가독성이 떨어집니다ㅠㅠ 터미널은 iterm2를 사용하고 있습니다

  • scrapy
  • 웹-크롤링
  • selenium
댓글 2 좋아요 0 조회수 259

저도 게시 버튼 누를 때 작동을 안 합니다...

미해결

페이스북 클론 - full stack 웹 개발

저도 밑에 질문을 해주신 분들처럼 코드를 다 작성하고 게시 버튼을 눌러도 post 나 tag 가 올라와 있지도 않고 console 창에 성공도 뜨지 않고 alert 창도 안 뜹니다... 제 컨테이너 공유 주소는 https://goor.me/s8RGf 입니다~~~

  • python
  • linux
  • javascript
  • django
  • HTML/CSS
  • 클론코딩
jungxav2 댓글 2 좋아요 1 조회수 216

IQR 설명 부분

미해결

R로 배우는 통계

본 강의에서 '지난 시간에 배운 IQR'이라고 하셨는데 배운 기억이 없어서 선생님 유튜브를 찾아보니 목록 순서가 뒤바뀌어서 문제가 생긴 것이네요. 이 다음 강의(상자그림 (이론편))를 먼저 듣고 이 강의를 들으시면 순서가 맞게 될 것 같습니다.

  • 인프런 신규강의 (무료)
  • 통계
  • R
  • 인프런 신규강의 (무료)
길벗의 앤Anne Kim 댓글 1 좋아요 1 조회수 229

7.8 단어 세기 예제

미해결

홍정모의 따라하며 배우는 C언어

교수님께서 작성하신 단어 세기 예제를 보면 while문 안의 if문들이 다 if(expression) 형태인데, 왜 else if는 사용하지 않으신 건가요?? 전에 강의에서 if (income <= base1) else if (income <= base2) 이면 else if의 정확한 범위는 base1 < income <= base2 가 된다고 하셨는데 그런 특징과 관련된 건가요? 만약 그런거라면 아래와 같이 코드를 작성해도 될까요? 두 가지 경우 모두 봐주세요.. while (( ch = getchar ()) != STOP ) { if (! isspace ( ch )) { character ++; if (! word_flag ) { word ++; word_flag = true ; } if (! line_flag ) { line ++; line_flag = true ; } } else word_flag = false ; if ( ch == ' \n ' ) line_flag = false ; } while (( ch = getchar ()) != STOP ) { if (! isspace ( ch )) character ++; if (! isspace ( ch ) && ! line_flag ) { line ++; line_flag = true ; } else if ( ch == ' \n ' ) line_flag = false ; if (! isspace ( ch ) && ! word_flag ) { word ++; word_flag = true ; } else if ( isspace ( ch )) word_flag = false ; }

  • c
tjekqls7 댓글 1 좋아요 1 조회수 198

npm run dev not working

미해결

Svelte 입문 강의 - A부터 Z까지

cnpx degit sveltejs/template-webpack my-svelte-project-webpack 으로 설치하여, npm i -> npm run dev 를 하는데, 작동을 하지 않습니다 ㅠㅠ 기존 rollup 프로젝트로 설치하는 방식은 npm run dev 까지 잘 됬는데, webpack 프로젝트로는 npm run dev가 안됩니다 ㅠ 어떤 문제때문인지 알 수 있을 까요 ??

  • svelte
압력산대 사가사가덕 댓글 3 좋아요 1 조회수 540

인기 태그

인프런 TOP Writers

주간 인기글