2014-10-08 4 views
15

मेरे पास निम्न सरल दृश्य है। इस त्रुटि के परिणामस्वरूप क्यों है?दृश्य एक HttpResponse ऑब्जेक्ट वापस नहीं किया था। यह बदले में कोई नहीं

The view auth_lifecycle.views.user_profile didn't return an HttpResponse object. It returned None instead.

"""Renders web pages for the user-authentication-lifecycle project.""" 
from django.shortcuts    import render 
from django.template    import RequestContext 
from django.contrib.auth   import authenticate, login 

def user_profile(request): 
    """Displays information unique to the logged-in user.""" 

    user = authenticate(username='superuserusername', password='sueruserpassword') 
    login(request, user) 

    render(request, 'auth_lifecycle/user_profile.html', 
      context_instance=RequestContext(request)) 

उत्तर

40

क्योंकि दृश्य वापसीrender, बस इसे फोन नहीं करना चाहिए।

return render(request, 'auth_lifecycle/user_profile.html', 
      context_instance=RequestContext(request)) 
2

के अंतिम पंक्ति में बदलें मैं एक UpdateView

मैं इस किया था का उपयोग कर एक ही त्रुटि थी:

if form.is_valid() and form2.is_valid(): 
    form.save() 
    form2.save() 
    return HttpResponseRedirect(self.get_success_url()) 

और मैं बस कर हल:

if form.is_valid() and form2.is_valid(): 
    form.save() 
    form2.save() 
    return HttpResponseRedirect(reverse_lazy('adopcion:solicitud_listar')) 
संबंधित मुद्दे