首页 \ 问答 \ Django 404尾随斜线(Django 404 on trailing slash)

Django 404尾随斜线(Django 404 on trailing slash)

当我使用以下urlconf时:

url(
    r'^titles/(?P<order_item_id>\d+)/localized$',
    'metadataorder.title.views.localized_metadata',
    name='localized_metadata',
    ),

有用。 但是,如果我使用尾部斜杠(我的所有其他网址都使用),则为404s。

url(
    r'^titles/(?P<order_item_id>\d+)/localized/$',
    'metadataorder.title.views.localized_metadata',
    name='localized_metadata',
    ),

为什么会发生这种情况,我需要改变什么?


When I use the following urlconf:

url(
    r'^titles/(?P<order_item_id>\d+)/localized$',
    'metadataorder.title.views.localized_metadata',
    name='localized_metadata',
    ),

it works. However if I use the trailing slash (which all my other urls use), it 404s.

url(
    r'^titles/(?P<order_item_id>\d+)/localized/$',
    'metadataorder.title.views.localized_metadata',
    name='localized_metadata',
    ),

Why is this occuring and what do I need to change?


原文:https://stackoverflow.com/questions/14430075
更新时间:2023-04-05 11:04

最满意答案

您可以使用sns.boxplotsns.stripplot函数中的order参数来订购“框”。 下面是一个如何执行此操作的示例(因为“最大到最低”并不完全清楚您的意思,即您希望根据条目对条目进行排序,我假设您要根据总和对它们进行排序对于他们的“距离”值,如果要根据不同的值对它们进行排序,您应该能够编辑解决方案以满足您的需求):

import numpy as np
import seaborn as sns
sns.set(style="ticks", palette="muted", color_codes=True)

# Load the example planets dataset
planets = sns.load_dataset("planets")

# Determine the order of boxes
order = planets.groupby(by=["method"])["distance"].sum().iloc[::-1].index

# Plot the orbital period with horizontal boxes
ax = sns.boxplot(x="distance", y="method", data=planets,
                 order=order, whis=np.inf, color="c")

# Add in points to show each observation
sns.stripplot(x="distance", y="method", data=planets, order=order,
              jitter=True, size=3, color=".3", linewidth=0)


# Make the quantitative axis logarithmic
ax.set_xscale("log")
sns.despine(trim=True)

这个修改过的代码(注意在sns.boxplotsns.stripplot函数中使用order参数)将产生下图:

有序的Boxplot


You can use the order argument in the sns.boxplot and sns.stripplot functions to order your "boxes". Here is an example of how to do this (since it is not completely clear what you mean by "greatest to lowest", i.e. which variable you want to sort the entries based on, I am assume you want to sort them based on the sum of their "distance" values, you should be able to edit the solution to fit your needs if you want to sort them based on a different value):

import numpy as np
import seaborn as sns
sns.set(style="ticks", palette="muted", color_codes=True)

# Load the example planets dataset
planets = sns.load_dataset("planets")

# Determine the order of boxes
order = planets.groupby(by=["method"])["distance"].sum().iloc[::-1].index

# Plot the orbital period with horizontal boxes
ax = sns.boxplot(x="distance", y="method", data=planets,
                 order=order, whis=np.inf, color="c")

# Add in points to show each observation
sns.stripplot(x="distance", y="method", data=planets, order=order,
              jitter=True, size=3, color=".3", linewidth=0)


# Make the quantitative axis logarithmic
ax.set_xscale("log")
sns.despine(trim=True)

This modifed code (notice the use of the order argument in the sns.boxplot and sns.stripplot functions) will produce the following figure:

Ordered Boxplot

相关问答

更多
  • 您链接的问题使用了一个factorplot 。 factorplot返回自己的类,该类具有一个名为set_xticklabels(rotation) 。 这与matplotlib Axes的set_xticklabels方法不同。 在链接问题的答案中,您还可以使用其他选项 ax = sns.boxplot(x='categories', y='oxygen', hue='target', data=df) ax.set_xticklabels(ax.get_xticklabels(),rotation=30 ...
  • 在这方面,Seaborn似乎与matplotlib一样: tips = sns.load_dataset("tips") ax = sns.boxplot(x=tips["total_bill"], whis=[5, 95]) plt.grid(True) plt.boxplot(tips["total_bill"], whis=[5, 95], vert=False) plt.grid(True) 我猜seaborn只是传递给matplotlib方法。 docstring可能是从早期版本的matplo ...
  • 我们用子图创建图: f, axes = plt.subplots(1, 2) 其中轴是每个子图的数组。 然后我们用参数ax告诉每个我们想要他们的子图。 sns.boxplot( y="b", x= "a", data=df, orient='v' , ax=axes[0]) sns.boxplot( y="c", x= "a", data=df, orient='v' , ax=axes[1]) 结果是: We create the figure with the subplots: f, ax ...
  • 使用color参数: import seaborn as sns tips = sns.load_dataset("tips") sns.boxplot(x="day", y="tip", data=tips, color="seagreen") Use the color parameter: import seaborn as sns tips = sns.load_dataset("tips") sns.boxplot(x="day", y="tip", data=tips, color="seag ...
  • 您需要编辑存储在ax.lines的Line2D对象。 下面是一个脚本来创建一个箱形图(基于这里的例子),然后根据你的问题中的样式编辑线条和艺术家(即没有填充,所有的线条和标记都是相同的颜色等) 您还可以修复图例中的矩形面片,但需要使用ax.get_legend().get_patches() 。 我还在第二个Axes上绘制了原始的boxplot作为参考。 import matplotlib.pyplot as plt import seaborn as sns fig,(ax1,ax2) = plt.su ...
  • 交换x和y列名称: import seaborn as sns sns.boxplot(x="weight_cat" y="Height", data=data) 目前,您正在尝试创建一个包含尽可能多的箱图的图表,因为有不同的高度值(24503)。 这对我的数据有用: 编辑 如果要水平显示箱线图,可以使用orient参数提供方向: sns.boxplot(x='Height', y='weight_cat', data=data, orient='h') 请注意,在这种情况下,交换x和y标签(如您的问题 ...
  • 我认为这里以简单的方式工作将需要一个像这样的数据帧: 价值方法 1.0 A p0 2.1 A p0 3.0 A p1 1.3 B p0 4.3 B p1 那么你可以用sns.boxplot(data=df, hue='method', x='p', y='value')得到你想要的sns.boxplot(data=df, hue='method', x='p', y='value') 我正在研究如何将df1和df2轻松地合并到像这样的数据框架中,但我不是真正的熊猫专家。 编辑:想出来,需要使用melt方法: ...
  • 这可能是一个丑陋的解决方案,但它有效,所以谁在乎 fig, ax = plt.subplots(1, 1) boxplot = sns.boxplot(x="Regularisierungsparameter", y="F1", data=data.sort("Regularisierungsparameter"), ax=ax) labels = ['%.5f' % float(t.get_text()) for t in ax.get_xticklabels()] ax.set_xticklabels( ...
  • 我鼓励你熟悉使用熊猫从数据框中提取定量信息。 例如,你可以做一件简单的事情来获得你正在寻找的值(和其他有用的值): planets.groupby("method").distance.describe().unstack() 它为每个方法打印一个有用值的表。 或者,如果你只是想要中位数: planets.groupby("method").distance.median() I would encourage you to become familiar with using pandas to ex ...
  • 您可以使用sns.boxplot和sns.stripplot函数中的order参数来订购“框”。 下面是一个如何执行此操作的示例(因为“最大到最低”并不完全清楚您的意思,即您希望根据条目对条目进行排序,我假设您要根据总和对它们进行排序对于他们的“距离”值,如果要根据不同的值对它们进行排序,您应该能够编辑解决方案以满足您的需求): import numpy as np import seaborn as sns sns.set(style="ticks", palette="muted", color_cod ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。