首页 \ 问答 \ 如何使用TemplateView在django1.5中使用POST?(How do I use POST in django1.5 with TemplateView?)

如何使用TemplateView在django1.5中使用POST?(How do I use POST in django1.5 with TemplateView?)

我试图将我的应用程序从django 1.4移植到1.5。 我改变了我的所有事件:

return direct_to_template(request, template)

至:

return TemplateView.as_view(template_name=template)(request)

这适用于所有使用GET的表单,但对于使用POST的表单,我最终在浏览器上留下了空白页。 没有任何错误,只是一个空白页。

在1.5中,我使用什么来替代POST的direct_to_template?


I am trying to port my app from django 1.4 to 1.5. I changed all my occurrences of:

return direct_to_template(request, template)

to:

return TemplateView.as_view(template_name=template)(request)

This works fine for all my forms that use GET, but for my forms that use POST I end up with a blank page on my browser. No error anywhere, just a blank page.

In 1.5 what do I use in place of direct_to_template for a POST?


原文:https://stackoverflow.com/questions/16565056
更新时间:2022-03-06 12:03

最满意答案

如果可以使用旋转和线性移动的组合定义运动,则无需执行每帧动画。

当它出来时,你的问题是你无法完全管理轮换的起源。

注意 :以下内容不仅适用于速度,还适用于所有css转换。

旋转原点是要旋转的项目的左上角

现在,如果要在不移动原点的情况下移动对象 ,可以使用translateX, translateY属性。 例如

.velocity({ translateX: "+=200", translateY: "25%"})

为了移动对象和原点 ,您需要设置或移动其x and y位置参数。 例如

.velocity({ x: "+=200", y: "25%" })

围绕中心旋转

例如,如果要在其中心旋转对象,则需要

  • 通过-w / 2和-h / 2转换对象,其中宽度和高度为w和h。
  • 旋转对象

围绕外部点旋转

如果您需要围绕项目旋转对象,只需先将对象从其原点移开适当的距离,然后再旋转它。

PEN显示了两个示例,其中绿色矩形围绕其中心旋转,蓝色围绕外部点通过正确组合平移和位置。


You do not need to do per frame animation if you can define the motion using combination of rotations and linear movements.

As it comes out, your issue is that you are not able to fully manage the origin of rotation.

NOTE : The following is applicable to not only velocity but all css transformations in general.

The origin of rotation is the top-left corner of the item to be rotated

Now, if you want to move the object without moving the origin, you can use the translateX, translateY properties. eg

.velocity({ translateX: "+=200", translateY: "25%"})

In order to move the object as well as the origin, you need to set or move its x and y position parameters. eg

.velocity({ x: "+=200", y: "25%" })

Rotation around center

As an example, if you want to rotate an object on its center,you need to

  • Translate the object by -w/2 and -h/2 where the width and height is w and h.
  • Rotate the object

Rotation around an external point

In case where you need to rotate the object around an item, simply first translate the object away from its origin by a suitable distance and then rotate it.

This PEN shows both examples where the green rectangle is rotated around its center and the blue one around an external point by combining translation and position correctly.

相关问答

更多
  • 如果可以使用旋转和线性移动的组合定义运动,则无需执行每帧动画。 当它出来时,你的问题是你无法完全管理轮换的起源。 注意 :以下内容不仅适用于速度,还适用于所有css转换。 旋转原点是要旋转的项目的左上角 现在,如果要在不移动原点的情况下移动对象 ,可以使用translateX, translateY属性。 例如 .velocity({ translateX: "+=200", translateY: "25%"}) 为了移动对象和原点 ,您需要设置或移动其x and y位置参数。 例如 .velocity ...
  • 简单的例子: 导入速度 import Velocity from 'velocity-animate'; 然后在componentDidMount中启动动画 import React, { Component } from 'react'; class VelocityExample extends Component { componentDidMount(){ Velocity(this.refs.block,{ scale: 2 },500) .then( ...
  • 尝试这可能会有所帮助,您可以使用TweenMax lib轻松控制任何类型的属性。