0
dreamhost에 Django + MySQL을 구축 중이지만 오류 메시지를 만났습니다.
렌더링 중에 예외가 발생했습니다 : (1064, "SQL에 오류가 있습니다 구문, 근처에 사용할 수있는 권리 구문에 대한 MySQL 서버 버전에 해당하는 설명서를 확인하십시오 '. tag
에 의해 ORDER)를 used_count
DESC, tag
name
ASC.'1 행에서 ")
MySQL 오류 메시지를 디버깅하는 방법 : 렌더링하는 동안 예외가 발생했습니다.
열심히 추적하고 오류를 발견 splot은 아래의 함수를 사용합니다 :
이 코드의 문제점을 확인하는 데 도움을 줄 수 있습니까?
def get_tags_by_questions(self, questions):
question_ids = []
for question in questions:
question_ids.append(question.id)
question_ids_str = ','.join([force_unicode(id) for id in question_ids])
related_tags = self.extra(
tables=['tag', 'question_tags'],
where=["tag.id = question_tags.tag_id AND question_tags.question_id IN (" + question_ids_str + ")"]
).distinct()
return related_tags
왜 장고의 ORM을 사용하지 않으십니까? 이를 사용하면 해당 SQL 세부 사항을 신경 쓸 필요없이 자동으로 추상화의 이점을 얻을 수 있습니다. –