안녕하세요 장고에서 WKT EWKT and HEXEWKB 에러가 발생하는데 어떻게 해야할까요?

조회수 1127회

지난번에 질문 올렸었던 views.py 의 내용입니다

그때 고마운 분의 도움으로 코드를 수정하여 지금

def post_list(request):
    lat = request.POST.get('user_lat', 'Nowhere')
    lon = request.POST.get('user_lon', 'Nowhere')
    userpoint = GEOSGeometry('POINT({}, {})'.format(lat,lon), srid=4326)

으로 수정했습니다.

그런데 이번에 python3 manage.py runserver 를 하니

이미지

이런 에러가 떴습니다 어떻게 해결해야할까요? (여기에 관련된 스택오버플로우를 찾아보니 이렇게 나왔습니다. : http://stackoverflow.com/questions/4770758/string-or-unicode-input-unrecognized-as-wkt-ewkt-and-hexewkb)

그리고 예전에 개인적으로 스택오버플로우에도 물어봤었는데 ( http://stackoverflow.com/questions/38430446/how-can-i-solve-this-errors-in-python-django/38430473?noredirect=1#comment64267284_38430473 )

이렇게 답변해줘서

코드를 이번엔

def post_list(request):
    lat = request.POST.get('user_lat', 'Nowhere')
    lon = request.POST.get('user_lon', 'Nowhere')
    userpoint = GEOSGeometry('POINT('+ lat +' '+ lon +')', srid=4326)

이렇게 바꿨지만 역시나 이번에도

같은 내용의 ValueError at / String or unicode input unrecognized as WKT EWKT, and HEXEWKB.

에러가 발생했습니다.

그래서 저 나름대로 구글링을 해 봤는데 이런 글을 발견했습니다. ( http://stackoverflow.com/questions/4770758/string-or-unicode-input-unrecognized-as-wkt-ewkt-and-hexewkb )

여기에서 나온대로 한번 해보기 위해


def post_list(request):
    lat = str(request.POST.get('user_lat', 'Nowhere'))
    lon = str(request.POST.get('user_lon', 'Nowhere'))
    mypoint = lat + " " + lon
    userpoint = GEOSGeometry('POINT('+ mypoint +')', srid=4326)


이렇게 해 봤지만 역시나 이번에도 ValueError at / String or unicode input unrecognized as WKT EWKT, and HEXEWKB.

가 발생했습니다. 어떻게 해결하는 것이 좋을까요?

https://docs.djangoproject.com/en/dev/ref/contrib/gis/db-api/#distance-lookups 여기의 example을 보고 참조했습니다.

  • (•́ ✖ •̀)
    알 수 없는 사용자

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)