我正在尝试在django rest框架中添加一个详细路径,该框架在url中使用多个变量。我试图设置自定义i=0
noofclasses = 2
alldata = ClassificationDataSet(400, 1, noofclasses)
while i<len(data):
alldata.addSample(data[i],labels[i])
i=i+1
tstdata_temp, trndata_temp = alldata.splitWithProportion( 10 )
tstdata = ClassificationDataSet(400, 1, noofclasses)
for n in xrange(0, tstdata_temp.getLength()):
tstdata.addSample( tstdata_temp.getSample(n)[0], tstdata_temp.getSample(n)[1] )
trndata = ClassificationDataSet(400, 1, noofclasses)
for n in xrange(0, trndata_temp.getLength()):
trndata.addSample( trndata_temp.getSample(n)[0], trndata_temp.getSample(n)[1] )
trndata._convertToOneOfMany( )
tstdata._convertToOneOfMany( )
fnn = buildNetwork( trndata.indim, 10, trndata.outdim, outclass=SoftmaxLayer )
trainer = BackpropTrainer( fnn, dataset=trndata, momentum=0.1, verbose=True, weightdecay=0.01)
trainer.trainEpochs( 20 )
,但是当我这样做时,我的django服务器崩溃了。
django.core.exceptions.ImproperlyConfigured:&#34; ^ some-object /(?P [^ /。] +)/ my_route /(?P [a-z0-9] +)/(?P [一个-Z0-9] +)/ $&#34;不是有效的正则表达式:重新定义组名&#39; pk&#39;作为第2组;是第1组
这是我到目前为止的详细路线。
url_path
我的目标是能够从具有以下格式的网址访问此端点:
@detail_route(url_path='my_route/(?P<pk>[a-z0-9]+)/(?P<other_pk>[a-z0-9]+)')
def my_route(self, request, pk, other_pk):
from rest_framework.response import Response
# ...
return Response(status=status.HTTP_204_NO_CONTENT)
任何帮助都将不胜感激。