I created api view for my mobile app which must accept words for search , when user enter none English words send error in the server this:
Internal Error
The server encountered an unexpected condition which prevented it from fulfilling the request.
Your server logs should have the complete traceback. You want to examine those first to identify exactly where the problem is occurring.
only when send non English letter this happen
I understand that. But you need to find what code is causing it to fail in that circumstance so you know where to look. If you don’t know where the problem is, you can’t fix it.
here are def
def VideosearchAPI(request,ser ):
sql =“SELECT * FROM dashboard_image,dashboard_imagescategory ,dashboard_medias WHERE (dashboard_image.category_id=dashboard_imagescategory.id) AND (dashboard_medias.id=dashboard_imagescategory.medias_id) AND (dashboard_medias.id=2) AND title LIKE '%”+ser+"%’ "
queryset = Image.objects.raw(sql)
qs_json = serialize(‘json’, queryset)
return HttpResponse(qs_json, content_type=‘application/json’)
Side note: When you post code here, please enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.
Side note #2: You have created an SQL-injection vulnerability. A malicious user could delete data from your database because of how you’ve written this. You really should be using the ORM for this query.
Side note #3: There’s nothing you are showing here that appears to be using DRF at all. This looks like a standard Django view to me. (Other than the malformed query)
You still need to post the complete traceback that you’re receiving from this error.
It would also help if you included a sample of the data that was being submitted that causes the error.