小编Erv*_*879的帖子

django-discover-runner和XML报告?

我有一个有效的Django应用程序,它已成功unittest-xml-reporting用于从我的单元测试中生成XML报告.

但是,该项目正在快速增长,我想将我的测试分解为每个应用程序中的单独文件.因此我安装django-discover-runner了找到我的所有测试文件并成功运行它们.

但是,django-discover-runner不会产生我需要的XML报告(对于Bamboo).

我发现了这个:

http://www.stevetrefethen.com/blog/Publishing-Python-unit-test-results-in-Jenkins.aspx

并尝试实现该建议(在我的每个test.py文件中),但没有生成XML.

如何使用它们django-discover-runnerunittest-xml-reporting发现我的测试并生成XML报告?

xml django unit-testing

8
推荐指数
2
解决办法
2110
查看次数

Django:get_object_or_404不是正确的解决方案,但它是什么?

我正在努力找到正确的解决方案,我正在努力做到这一点,并且非常感谢一些帮助.

目前,我有一个工作系统,它从数据库中获取"特殊"并在浏览器中显示它.用户可以在浏览器中编辑"特殊"并将其提交给数据库.然后向用户显示该更改.

问题是如果数据库中没有预先存在的"特殊",则"特殊"将不会更新.在我的views.py中,我有:

def changeSpecialOffer(theRequest):
    myProductUuid = theRequest.POST['myProductUuid']
    myNewSpecialOffer = theRequest.POST['myNewSpecialOffer']
    myProduct = get_object_or_404(Product, uuid=myProductUuid)
    myActiveSpecial = get_object_or_404(SpecialOffer.objects.filter(product=myProduct).filter(
                                                            active=True))
    try:
        myActiveSpecial.special = myNewSpecialOffer
        myActiveSpecial.save()
    except:
        return HttpResponse(myActiveSpecial, mimetype='text/plain')
    myActiveSpecial = SpecialOffer.objects.filter(product=myProduct).filter(
                                                            active=True)
    return HttpResponse(myActiveSpecial, mimetype='text/plain')
Run Code Online (Sandbox Code Playgroud)

我知道更新"特殊"不起作用的原因是因为get_object_or_404正确返回404错误,因为数据库中没有预先存在的"特殊".

我已经尝试了一段时间来找出解决这个问题的最佳方法,而不会破坏数据库中存在"特殊"的情况下的功能.

到目前为止,我已经尝试更换get_object_or_404with tryexcept,但是我遇到了保存功能的问题,例如'unicode' has no attribute 'save()'.

django

5
推荐指数
1
解决办法
9201
查看次数

无法获得bootstrap-lightbox工作......!

我确信我的问题有一个简单的解决方案,但对于我的生活,我无法弄清楚我做错了什么.

我正在尝试让bootstrap-lightbox在我的网站上工作(这是一个Django应用程序,如果这有任何区别).

我的标题中有以下内容:

<script type="text/javascript" src="/static/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/static/js/jquery-ui-1.8.16.custom.min.js"></script>
<script src="static/dash/bootstrap-lightbox.js"></script>
<script src="static/dash/excanvas.min.js"></script>
<script src="static/dash/bootstrap.min.js"></script>
<script src="static/dash/jquery.flot.min.js"></script>
<script src="static/dash/jquery.gritter.min.js"></script>
<script src="static/dash/jquery.flot.resize.min.js"></script>
<script src="static/dash/jquery.peity.min.js"></script>
<script src="static/dash/fullcalendar.min.js"></script>
<script src="static/dash/unicorn.dashboard.js"></script>
<script src="static/dash/unicorn.js"></script>
<script src="static/dash/custom.js"></script>
<link rel="stylesheet" href="static/dash/bootstrap.min.css" />
<link rel="stylesheet" href="static/dash/bootstrap-responsive.min.css" />
<link rel="stylesheet" href="static/dash/fullcalendar.css" />   
<link rel="stylesheet" href="static/dash/unicorn.main.css" />
<link rel="stylesheet" href="static/dash/jquery.gritter.css" />
<link rel="stylesheet" href="static/dash/unicorn.grey.css" class="skin-color" />
<link rel="stylesheet" href="static/dash/bootstrap-lightbox.css" />
Run Code Online (Sandbox Code Playgroud)

在我的HTML中:

<a data-toggle="lightbox" href="#worldlightbox" class="thumbnail"><img src="/static/img/pics/bg/thumbs/WorldThumb.jpg" alt=""></a>

<div class="lightbox" id="worldlightbox" style="display: none;">
<div class='lightbox-content'>
    <img src="/static/img/pics/bg/World.jpg">
</div>
Run Code Online (Sandbox Code Playgroud)

当我点击链接图像时,根本没有任何反应.控制台中没有错误,脚本正确加载..... …

css lightbox twitter-bootstrap

3
推荐指数
1
解决办法
7299
查看次数

使用Django-PayPal - PayPal IPN获得401

我正在尝试设置Django-Paypal并且已经从PayPal获得了回报.简而言之,在我的Apache访问日志中,每当我通过PayPal处理付款时(以及PayPal将结果发回给我的服务器),我都会收到以下信息:

173.0.82.126 - - [27/Oct/2012:16:42:52 +0200] "POST /my/super/secret/notify/url/ HTTP/1.0" 401 787 "-" "-"
Run Code Online (Sandbox Code Playgroud)

通知视图确实@csrf_exempt用于解决此错误,但仍然无法正常工作.

如果有人能告诉我如何解决这个问题(这显然是权限/授权问题),我将非常感激!

PS:我已经尝试添加WSGIPassAuthorization到我的apache配置文件,这也没有帮助.

django-paypal http-status-code-401 paypal-ipn

1
推荐指数
1
解决办法
679
查看次数