Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django,截断了不正确的双精度值:_Django_Django Urls - Fatal编程技术网

Django,截断了不正确的双精度值:

Django,截断了不正确的双精度值:,django,django-urls,Django,Django Urls,我有一个错误: Truncated incorrect DOUBLE value: 'asinox' 此错误来自我的SEO url: http://127.0.0.1:8000/user/asinox/2010/dec/30/1/este-pantalon-lo-compre-en-plaza-lama-una-aperidad/ “asinox”是用户名(usuario),并通过以下方式路由URL: (r'^(?P<usuario>[-\w]+)/(?P<year>

我有一个错误:

Truncated incorrect DOUBLE value: 'asinox'
此错误来自我的SEO url:

http://127.0.0.1:8000/user/asinox/2010/dec/30/1/este-pantalon-lo-compre-en-plaza-lama-una-aperidad/
“asinox”是用户名(usuario),并通过以下方式路由URL:

(r'^(?P<usuario>[-\w]+)/(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{2})/(?P<pk>\d+)/(?P<slug>[-\w]+)/$', shared),
请问你对此有何想法


谢谢,我的英语很抱歉。

正则表达式与URL完全不匹配。您的URL以文本字符串“user”开头,该字符串不在正则表达式中;regex还需要一个整数PK值,而URL没有。

我认为问题在于urls.py中的[-\w]+,但我不确定regex是否是您想要的。我修复了一个问题,我调用了一个用户,如“string”…和用户(id)是一个int。我猜应该是来自另一个url.py的某种包含,1是主键。这个答案看起来是正确的。它将文本“user”作为您的用户名,然后将“asinox”传递给。。。实际上,asinox不应该被传递到年中,因为年只接受数字。这看起来根本不应该匹配。
def shared(request,usuario,year, month,day, pk, slug):
    import datetime, time
    date_stamp= time.strptime(year+month+day, "%Y%b%d")
    pub_date = datetime.date(*date_stamp[:3])
    shared = get_object_or_404(Show,usuario=usuario,
                               pub_date__year=pub_date.year,
                               pub_date__month=pub_date.month,
                               pub_date__day=pub_date.day,
                               pk=pk,
                               slug=slug)
    return render_to_response('site/account/shared.html',
                              {'shared': shared},
                              context_instance=RequestContext(request))