首页 \ 问答 \ 绑在Django管理员的模特历史上(Tying in to Django Admin's Model History)

绑在Django管理员的模特历史上(Tying in to Django Admin's Model History)

设置:

  • 我正在使用Django应用程序,它允许用户在数据库中创建一个对象,然后返回并按需要进行编辑。
  • Django的管理员站点保留对通过管理站点进行的更改的历史记录。

问题:

  • 如何将我的应用程序挂接到管理站点的更改历史记录中,以便我可以看到用户对其“内容”所做的更改的历史记录?

The Setup:

  • I'm working on a Django application which allows users to create an object in the database and then go back and edit it as much as they desire.
  • Django's admin site keeps a history of the changes made to objects through the admin site.

The Question:

  • How do I hook my application in to the admin site's change history so that I can see the history of changes users make to their "content"?

原文:https://stackoverflow.com/questions/987669
更新时间:2022-11-17 11:11

最满意答案

我遇到了同样的问题,我找到了一个解决方案。 它有点黑客,但它做的伎俩。 所以基本上你需要把你的VideoView放入FrameLayout。 在视频视图中,您需要添加另一个FrameLayout与您的视频的背景,当您的视频加载并准备播放时,您隐藏占位符。

<FrameLayout
  android:id="@+id/frameLayout1"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_gravity="center"
  android:layout_marginTop="50dip" >

  <VideoView
    android:id="@+id/geoloc_anim"
    android:layout_width="fill_parent"
    android:layout_height="172dip" android:layout_gravity="top|center" android:visibility="visible"/>

  <FrameLayout
      android:id="@+id/placeholder"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" android:background="@drawable/fondvert_anim">
  </FrameLayout>

在你的活动中,你需要实现OnPreparedListener并添加它

//Called when the video is ready to play
public void onPrepared(MediaPlayer mp) {

    View placeholder = (View) findViewById(R.id.placeholder);

    placeholder.setVisibility(View.GONE);
}

所以当视频准备好的时候,我们隐藏占位符,这个技巧避免了黑色的闪烁屏幕。

希望这个有帮助的人。


I got the same problem and i found a solution. Its a little bit hacky but it do the trick. So basically you need to put your VideoView into a FrameLayout. Over the videoview you need to add another FrameLayout with the background of your video and when your video is loaded and ready to play you hide the placeholder.

<FrameLayout
  android:id="@+id/frameLayout1"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:layout_gravity="center"
  android:layout_marginTop="50dip" >

  <VideoView
    android:id="@+id/geoloc_anim"
    android:layout_width="fill_parent"
    android:layout_height="172dip" android:layout_gravity="top|center" android:visibility="visible"/>

  <FrameLayout
      android:id="@+id/placeholder"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" android:background="@drawable/fondvert_anim">
  </FrameLayout>

In your activity you need to implements OnPreparedListener and add this

//Called when the video is ready to play
public void onPrepared(MediaPlayer mp) {

    View placeholder = (View) findViewById(R.id.placeholder);

    placeholder.setVisibility(View.GONE);
}

So when the video is ready we hide our placeholder and that trick avoid the black flicker screen.

Hope this help someone.

相关问答

更多
  • 视频的宽高比可能与屏幕的宽高比或VideoView占用的屏幕部分不匹配。 你的选择是: 使用android:gravity定位黑条,例如将其居中作为“信箱”效果,或者 尝试使用负边距,因此太长尺寸的部分位于屏幕之外,但这会切断视频的那些部分 后一种技术适用于相机预览; 我没有尝试过视频和VideoView 。 它还需要一些运行时计算,除非您事先知道视频的宽高比。 The aspect ratio of a video may not match the aspect ratio of the screen, ...
  • 由Praful解决,在Manifest.xml中添加Internet权限 AndroidManifest.xml中
    我遇到了同样的问题,我找到了一个解决方案。 它有点黑客,但它做的伎俩。 所以基本上你需要把你的VideoView放入FrameLayout。 在视频视图中,您需要添加另一个FrameLayout与您的视频的背景,当您的视频加载并准备播放时,您隐藏占位符。
  • 请使用以下xml替换fragment_two.xml
  • 代码是正确的。 所有错误都与视频分辨率有关。 我用不同的分辨率替换了视频,它正在工作 The code is correct. All the errors are related to video resolution. I have replaced video with different resolution , and it is working
  • 最好的办法可能是创建自己的VideoView子类,重写onMeasure(int,int)方法,并获取屏幕尺寸并修改VideoView的高度/宽度以匹配设备的正确高度/宽度。 如果你不希望这样做,那么你可能更容易的其他选项是在全屏对话框中启动视频,或者可以将LayoutParams设置为运行时生成的静态大小: VideoView v = (VideoView) findViewById(R.id.videoView_intro); v.setVideoURI(Uri.parse("android.resou ...
  • 试试这个代码,它的工作, public class PlayVideo extends Activity { private String videoPath ="url"; private static ProgressDialog progressDialog; String videourl; VideoView videoView ; protected void onCreate(Bundle savedInstanceState) { super.onCre ...
  • 试试这种方式: videoview.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { videoview.stopPlayback(); videoview.setVideoURI(uri); videoview.start(); } }); video ...
  • 好的,我发现了问题, 问题是我正在使用 vv.setOnPreparedListener(new OnPreparedListener() { public void onPrepared(MediaPlayer arg0) { vv.start(); } } 当手机暂停时,它会传递此功能,因为它准备下一个会话。 我只是用布尔值控制它, @Override public void onResume() { super.onRes ...
  • 你所要求的实际上是不可能的。 如果要保持纵横比,则意味着必须按相同的百分比缩放宽度和高度。 如果这恰好恰好适合你,那你很好。 如果没有,你有黑条或你必须打破纵横比来填补它。 您需要的视频完全适合每种屏幕尺寸。 大多数屏幕是16:9或4:3,所以如果您有两种格式的视频,您将适合大多数屏幕,但总会有一些异常值。 What you're asking for is physically impossible. If you want to maintain aspect ratio, that means you ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)