我想在django中测试我的网址,但是我收到了错误消息.
这是我的代码:
urls.py
url(r'^create/(?P<userName>[0-9a-zA-Z-]+)/$', views.create, name='create'),
Run Code Online (Sandbox Code Playgroud)
test.py
from django.test import TestCase, Client
client = Client()
def test_create(self):
"""Test the url for "create"
"""
response = self.client.get('/mission/create/' + str(self.userName))
self.assertEqual(response.status_code, 200)
Run Code Online (Sandbox Code Playgroud)
我会得到这个结果:
FAIL: test_create (mission.tests.MissionUrlTests)
Test the url for "create"
----------------------------------------------------------------------
Traceback (most recent call last):
File "/actinbox/mission/tests.py", line 122, in test_create
self.assertEqual(response.status_code, 200)
AssertionError: 301 != 200
Run Code Online (Sandbox Code Playgroud)
请帮我处理我的代码.先感谢您.
我想在这里得到一些帮助。我想要的只是将 Celery 和 RabbitMQ 添加到我的 django 项目中。我遵循了本教程Celery - First Step with Django。它能够工作。但是我怎样才能自定义这个设置呢?
CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672//'
Run Code Online (Sandbox Code Playgroud)
如何更改guest真实的用户名和密码?我应该在哪里配置它,例如:amqp://userid:1234@sample.com:5672
我是javascript的新手.这是我的代码,如果它在列表中找到'anna',我希望它返回true
var userList = [{'username':'anna','email':'anna@a.c'},
{'username':'benny','email':'benny@a.c'},
{'username':'kathy','email':'kathy@a.c'}]
return userList.includes('anna')
Run Code Online (Sandbox Code Playgroud)
非常感谢你的帮助
我正在创建一种上传文件的方法,但是我想检查文件大小,因为我只想允许 5mb 作为最大限制。
我想做这样的事情
def handle_uploaded_file(thisFile):
if thisFile > 5mb:
return "This file is more than 5mb"
else:
with open('some/file/' + str(thisFile), 'wb+') as destination:
for chunk in thisFile.chunks():
destination.write(chunk)
return "File has successfully been uploaded"
Run Code Online (Sandbox Code Playgroud) django ×3
python ×3
celery ×1
django-urls ×1
file-upload ×1
javascript ×1
rabbitmq ×1
testing ×1