- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我在运行 python manage.py test
时收到 ValueError
。我的项目名为 fellow_go
,我目前正在开发一个名为 pickup
的应用程序。
请注意,这个错误是在最近对 Django 的提交中添加的:Fixed #24452 -- Fixed HashedFilesMixin correctness with nested paths. .
======================================================================
ERROR: test_view_url_exists_at_desired_location (pickup.tests.test_view.HomePageViewTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/sunqingyao/PycharmProjects/fellow_go/pickup/tests/test_view.py", line 10, in test_view_url_exists_at_desired_location
resp = self.client.get('/', follow=True)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/test/client.py", line 536, in get
**extra)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/test/client.py", line 340, in get
return self.generic('GET', path, secure=secure, **r)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/test/client.py", line 416, in generic
return self.request(**r)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/test/client.py", line 501, in request
six.reraise(*exc_info)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/utils/six.py", line 686, in reraise
raise value
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/core/handlers/base.py", line 217, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/core/handlers/base.py", line 215, in _get_response
response = response.render()
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/response.py", line 107, in render
self.content = self.rendered_content
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/response.py", line 84, in rendered_content
content = template.render(context, self._request)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/backends/django.py", line 66, in render
return self.template.render(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/base.py", line 207, in render
return self._render(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/test/utils.py", line 107, in instrumented_test_render
return self.nodelist.render(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/loader_tags.py", line 177, in render
return compiled_parent._render(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/test/utils.py", line 107, in instrumented_test_render
return self.nodelist.render(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/base.py", line 990, in render
bit = node.render_annotated(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/template/base.py", line 957, in render_annotated
return self.render(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/templatetags/static.py", line 105, in render
url = self.url(context)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/templatetags/static.py", line 102, in url
return self.handle_simple(path)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/templatetags/static.py", line 117, in handle_simple
return staticfiles_storage.url(path)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 162, in url
return self._url(self.stored_name, name, force)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 141, in _url
hashed_name = hashed_name_func(*args)
File "/Users/sunqingyao/Envs/django_tutorial/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 432, in stored_name
raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for 'favicon.ico'
----------------------------------------------------------------------
fellow_go/settings.py
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
# ......
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
fellow_go/urls.py
urlpatterns = i18n_patterns(
url(r'^$', HomePageView.as_view(), name='index'),
url(r'^pickup/', include('pickup.urls')),
url(r'^accounts/', include('django.contrib.auth.urls')),
url(r'^admin/', admin.site.urls),
prefix_default_language=False
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
fellow_go/pickup/views.py
class HomePageView(TemplateView):
template_name = 'index.html'
fellow_go/templates/index.html
<link rel="icon" href="{% static "favicon.ico" %}">
fellow_go/pickup/tests/test_view.py
class HomePageViewTest(TestCase):
def test_view_url_exists_at_desired_location(self):
resp = self.client.get('/', follow=True)
self.assertEqual(resp.status_code, 200)
我有一个 favicon.ico
文件:
奇怪的是,python manage.py runserver
没有发生错误:
/Users/sunqingyao/Envs/django_tutorial/bin/python3.6 /Users/sunqingyao/PycharmProjects/fellow_go/manage.py runserver 8000
Performing system checks...
System check identified no issues (0 silenced).
May 24, 2017 - 22:09:25
Django version 1.11.1, using settings 'fellow_go.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[24/May/2017 22:09:28] "GET / HTTP/1.1" 200 6276
[24/May/2017 22:09:28] "GET /static/css/style.min.css HTTP/1.1" 200 2474
[24/May/2017 22:09:28] "GET /static/css/ie10-viewport-bug-workaround.css HTTP/1.1" 200 430
[24/May/2017 22:09:28] "GET /static/js/ie10-viewport-bug-workaround.js HTTP/1.1" 200 685
[24/May/2017 22:09:28] "GET /static/js/opt-in.js HTTP/1.1" 200 511
[24/May/2017 22:09:28] "GET /static/css/datetimepicker.css HTTP/1.1" 200 12351
[24/May/2017 22:09:28] "GET /static/js/bootstrap-datetimepicker.js HTTP/1.1" 200 55741
[24/May/2017 22:09:35] "GET /static/favicon.ico HTTP/1.1" 200 766
Not Found: /apple-touch-icon-precomposed.png
[24/May/2017 22:09:35] "GET /apple-touch-icon-precomposed.png HTTP/1.1" 404 2678
Not Found: /apple-touch-icon.png
[24/May/2017 22:09:35] "GET /apple-touch-icon.png HTTP/1.1" 404 2642
请告诉我我的代码有什么问题。
最佳答案
尝试运行:
python manage.py collectstatic
测试现在有效吗?如果是这样,这可能是导致问题的配置:
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
从 whitenoise v4 开始,这将失败,您应该使用:
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
关于python - 值错误 : Missing staticfiles manifest entry for 'favicon.ico' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44160666/
Eclipse 提示此代码“类型参数 Entry 隐藏了类型 Map.Entry”: import java.util.Map.Entry; public class Test { stat
这两个for语句是等价的。 import java.util.Map; import java.util.Map.Entry; for (Map.Entry entry: map.entrySet()
我想在 python 字典中添加一个键/值,它依赖于现有的键/值。示例 x = {} x["length"] = 12 x["volume"] =x["lenght"] * 10 行得通;但是有没有可
我使用 NuGet 将我的 EntityModel 升级到版本 4.3。 现在我想更改我的 EntityObject.State,但找不到 .Entry() 方法。 当前状态是已删除。 这就是我想要做
我是 Java 新手,正在使用 HashMap 在 Mac 上编写 Java。 但是我遇到了一个问题,找不到答案 import java.util.Map; import java.util.Hash
我正在切换一个小应用程序(Win 7/64 上的 Python 2.7.3/32)来使用 ttk,但我在使 ttk.Entry 按照 tk.Entry 的方式工作时遇到问题;当我设置其内容时,ttk.
为什么我需要在 i.next(); 前面加上 (Map.Entry) ?为什么我不能只有 Map.Entry m = i.next();? 对不起。它是一个 HashMap。 最佳答案 因为它显然不是
我的 xPage SSJS 失败: viewEntry = view.getNext(viewEntry); 有错误 Notes error: Entry not found in index 我确实
我正在使用 DataTable在我的申请中。 我想隐藏左下角的细节,我该怎么做? “显示 1,657 个条目中的 1 到 10 个(从 9,044 个条目中筛选出来)” 这是我的设置: $('#inv
我有两列,一个时间戳和一个已选择卡片的数字。 card added 1 2016-09-23 13:48:48 3 2016-09-23 13:48:48 1
我正在使用 Entity Framework 4.1,并且我有我的 DbContext Override SaveChanges 来审核属性更改。从“GetEntryValueInString”返回空
我正在使用 Tkinter 在 Python 3 上编写 GUI,但每次使用 Entry() 时,我都会收到名称错误。 我尝试了一个更简单的代码版本,(写在下面),但它仍然导致了 NameError:
我刚刚创建了一个插入方法来对数组进行排序,这是我在该方法中完成的代码; public static void insertionSort (Entry[] array2){ for (int
使用这个例子1对于 n:n 关系: (来源:tekstenuitleg.net) 设置主要或主要多对多字段的最佳方法是什么?示例:假设我想将经销商“Devrolijke drinker”(ID AB9
是否可以使用 Entry 通过 AsRef 获取值的 API , 但用 Into 插入它? 这是工作示例: use std::collections::hash_map::{Entry, HashMa
是否可以使用 Entry 通过 AsRef 获取值的 API , 但用 Into 插入它? 这是工作示例: use std::collections::hash_map::{Entry, HashMa
是否可以使用 Entry 通过 AsRef 获取值的 API , 但用 Into 插入它? 这是工作示例: use std::collections::hash_map::{Entry, HashMa
表定义: CREATE TABLE PositionalDataNGS ( Date DATE, Time TIME(3) , X FLOAT(5), Y FLOAT(5), D FLOAT(5) ,
我的平台: PHP 和 MySQL 我这里有什么: 我有 4 个表,分别是“books”、“book_type”、“book_categories”、“all_categories”。 我想做什么:
I am using MySQL 5.1.56, MyISAM. My table looks like this:我使用的是MySQL 5.1.56,MyISAM。我的桌子是这样的: CR
我是一名优秀的程序员,十分优秀!