The view blog.views.create didn't return an HttpResponse object. It returned None instead.can any one help me this issue please nooob here

5,060 views
Skip to first unread message

harsh sharma

unread,
Sep 11, 2017, 7:36:25 PM9/11/17
to Django users
 here i m learning django and i m stuck on one thing 
the web page returning 
The view blog.views.create didn't return an HttpResponse object. It returned None instead.


and here is my views.py  file


def home(request):

story = Story.objects.all()
return render_to_response('show.html',{'story':story})



def create(request):
if request.method == "get":
form = storyform()
return render(request,'form.html',{'form':form})
elif request.method == "post":
form= storyform(request.POST)
form.save()
return HttpResponseRedirect('/home')

Luis Zárate

unread,
Sep 11, 2017, 8:09:19 PM9/11/17
to django...@googlegroups.com
if request.method == "GET":
if request.method == "POST":

Uppercase is needed.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/067af0b0-6761-4daf-a1c0-02fcd1585048%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
"La utopía sirve para caminar" Fernando Birri


Melvyn Sopacua

unread,
Sep 13, 2017, 9:54:22 AM9/13/17
to django...@googlegroups.com
And to be complete:

from django.http.response import HttpResponseNotAllowed
# in create
else:
return HttpResponseNotAllowed(['get', 'post'])
>> email to django-users...@googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/067af0b0-6761-4daf-a1c0-02fcd1585048%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAG%2B5VyMqn-Z%3Das%3DYxf_oph5yvDfUi%2BZWU1Uf_554fOTC2y3rsA%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Melvyn Sopacua
Reply all
Reply to author
Forward
0 new messages