I'm trying to show dynamicly details of a certain object, getting them from a sqlite3 database. I based my code on a tutorial, everything is exactly the same, but I get a 500 Internal Server Error on my page (but the tutorial runs perfectly).
I have python 3.3 and django 1.6 installed.
Here's my code:
url.py :
url(r'^cargar-inmueble/(?P<id>\d+)$', 'inmobiliaria.views.cargar_inmueble', name='cargar_inmueble_view'),
views.py :
import json
from django.http import HttpResponse, Http404
from inmobiliaria.models import *
....
def cargar_inmueble(request, id):
if request.is_ajax():
inmueble = Inmueble.objects.get(id=id)
return HttpResponse( json.dumps({'nombre': inmueble.nombre,
'descripcion': inmueble.descripcion, 'foto' : inmueble.foto }),
content_type='application/json; charset=utf8')
else:
raise Http404
hover.js (it's the main js script, have to rename it)
$(document).on("ready", inicio );
function inicio() {
...
$("#slider ul li.inmueble").on("click", "a", cargar_inmueble);
}
function cargar_inmueble(data) {
var id = $(data.currentTarget).data('id');
$.get('cargar-inmueble/' + id, ver_inmueble);
}
Looking at the console of the chrome dev tools, everytime I click the link that calls "cargar_inmueble", I get this error and "ver_inmueble" is never called.. It's my first web site using python so I'm pretty lost!