当我冲浪时:
http://127.0.0.1:8000/getEmail/getMyMessages/
我有以下错误:
getMyMessages() takes no arguments (1 given)
myapplication / urls.py包含:
urlpatterns = patterns('',
# Examples:
url(r'^polls/', include('polls.urls')),
url(r'^getEmail/', include('get_new_emails.urls')),
我有一个名为'get_new_emails'的应用,get_new_emails / urls.py包含:
urlpatterns = patterns('',
#url(r'^$', views.index, name='index')
url(r'getMyMessages', views.getMyMessages)
)
来自get_new_emails / views.py的:
def getMyMessages():
from django_mailbox.models import Message
qs = Message.objects.all()
count = 0
for i in qs:
count += 1
output = output + str(count)+ " " + i.text +'<br>' + '<br>'
return HttpResponse(output)
我该如何解决这个问题?
答案 0 :(得分:1)
您忘记了函数的请求参数:
def getMyMessages(request):
from django_mailbox.models import Message
qs = Message.objects.all()
count = 0
for i in qs:
count += 1
output = output + str(count)+ " " + i.text +'<br>' + '<br>'
return HttpResponse(output)