• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

301 != 200문제 조치 방법

20.06.24 00:13 작성 조회수 158

0

def test_post_detail(self):
Post_000 = Post.objects.create(
title='The Firt Step',
content='Hello, World!',
created=timezone.now(),
author=self.author_000
)

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)
print(response)
self.assertEqual(response.status_code, 200)

soup = BeautifulSoup(response.content, 'html.parser')
title = soup.title

self.check_navbar(soup)

FAIL: test_post_detail (blog.tests.TestView)

----------------------------------------------------------------------

Traceback (most recent call last):

  File "C:\github\django_website_2020\blog\tests.py", line 61, in test_post_detail

    self.assertEqual(response.status_code, 200)

AssertionError: 301 != 200

똑같이 따라쳤는데 301 != 200 에러가 고쳐지질 않습니다..

구글에 쳐보니 리디렉션? 문제인 것 같은데, 조치 방법을 잘 모르겠습니다. ㅠㅠ

답변 1

답변을 작성해보세요.

0

테스트 코드만 봐서는 알기가 어렵네요. models.py와 views.py 파일에서 관련된 내용도 보여주실 수 있나요?