dimanche 28 juin 2015

Django: render_to_response doesn't work

I have a template perfil.html and want to send this to it:

return render_to_response('perfil.html', query_data,  context_instance=RequestContext(request), {'pseudonimo': usuario.pseudonimo,'seguidores': seguidores(usuario.pseudonimo), 'sigue':sigue(usuario.pseudonimo), 'posts':"En pruebas"})

but it doesn't work. This is the error I have:

Request Method: GET
Request URL:    http://localhost:8000/mi_perfil/
Django Version: 1.8
Exception Type: SyntaxError
Exception Value: non-keyword arg after keyword arg (views.py, line 181)
Exception Location: /home/rebecca/DSI/pretec/pretec/urls.py in <module>, line 3
Python Executable:  /home/rebecca/DSI/env-pretec/bin/python
Python Version: 2.7.3

If I do this:

return render(request,'perfil.html', {'pseudonimo': usuario.pseudonimo,'seguidores': seguidores(usuario.pseudonimo), 'sigue':sigue(usuario.pseudonimo), 'posts':"En pruebas"})

it works, and if I do this:

return render_to_response('perfil.html', query_data, context_instance=RequestContext(request))

it works too but I want to include the two options in the render_to_response

This is my function in the views.py:

def mi_perfil(request):
   usuario = Usuario.objects.get(pseudonimo = request.session['member_id'])
   query = Usuario.objects.all()

   query_data = {
       "user_data" : query
   }
   print query_data
   return render_to_response('perfil.html', query_data, context_instance=RequestContext(request), {'pseudonimo': usuario.pseudonimo,'seguidores': seguidores(usuario.pseudonimo), 'sigue':sigue(usuario.pseudonimo), 'posts':"En pruebas"})

What i am doing wrong? How can I fix it?

Aucun commentaire:

Enregistrer un commentaire