【发布时间】:2015-06-26 23:40:57
【问题描述】:
urls.py
from housepost.views import ListingPost
...
url(r'^house_post/$', ListingPost.as_view(), name='post_house'),
...
views.py
from django.http import HttpResponse
from django.contrib import messages
from django.views.generic import View
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
class ListingPost(View):
def get(self, request, *args, **kwargs):
messages.error(request, 'asdf', extra_tags = 'error')
return HttpResponse('Hi')
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
super(ListingPost, self).dispatch(*args, **kwargs)
我在获取请求时返回了一个 HttpResponse,但我不断收到错误消息:
错误信息
view housepost.views.ListingPost 没有返回 HttpResponse 对象。它返回 None 。
我哪里出错了?
【问题讨论】:
-
对不起,我忽略了发布它。但它就在那里。
-
您是否正在实施其他类似
dispatch的东西? -
@JuniorCompressor 是的,我是。
-
是登录的用户,在这种情况下。你已经放置了一个装饰器来检查它。
-
@user2190496 对于您的下一个问题...您看到省略相关信息是一件坏事