Django Indentation 오류
-
18-09-2019 - |
문제
나는 Django를 처음 접했고 튜토리얼 에서이 코드를 시도하고있었습니다. 그러나 이제 다음 오류로 인해 프로그램을 실행할 수 없습니다.
IndentationError at /
('unexpected indent', ('D:\\django_workspace\\django_bookmarks\\..\\django_bookmarks\\bookmarks\\views.py', 14, 4, ' return HttpResponse(output)\n'))
Request Method: GET
Request URL: http://localhost:8000/
Exception Type: IndentationError
Exception Value:
('unexpected indent', ('D:\\django_workspace\\django_bookmarks\\..\\django_bookmarks\\bookmarks\\views.py', 14, 4, ' return HttpResponse(output)\n'))
Exception Location: D:\django_workspace\django_bookmarks\..\django_bookmarks\urls.py in <module>, line 2
Python Executable: C:\Python26\python.exe
Python Version: 2.6.4
Python Path: ['D:\\django_workspace\\django_bookmarks', 'C:\\Python26', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26\\lib\\site-packages']
Server time: Tue, 9 Mar 2010 19:18:32 +
my views.py 파일 코드는 다음과 같습니다.
from django.http import HttpResponse, Http404
from django.contrib.auth.models import User
from django.template import Context
from django.template.loader import get_template
def main_page(request):
template = get_template('main_page.html')
variables = Context({
'head_title': 'Django Bookmarks',
'page_title': 'Welcome to Django Bookmarks',
'page_body': 'Where you can store and share bookmarks!'
})
output = template.render(variables)
return HttpResponse(output)
def user_page(request, username):
try:
user = User.objects.get(username=username)
except:
raise Http404('Requested user not found.')
bookmarks = user.bookmark_set.all()
template = get_template('user_page.html')
variables = Context({
'username': username,
'bookmarks': bookmarks
})
output = template.render(variables)
return HttpResponse(output)
이 문제를 교정하도록 도와주세요! 미리 감사드립니다.
해결책
아마도 탭을 공백과 혼합하고있을 가능성이 높습니다.
다른 팁
먼저이 오류가 발생하는 선을 찾습니다. 줄을 완전히 삭제하십시오. 앞선의 끝으로 이동 한 다음 Enter를 누릅니다. 이제 줄을 입력하십시오.
제휴하지 않습니다 StackOverflow