[英]Django Admin and Dajax
I am new to using anything ajax related, so please excuse my ignorance. 我不熟悉任何与ajax相关的东西,所以请原谅我的无知。
I am working with the example here and trying to get it to work in the Django Admin. 我在这里使用示例,并尝试使其在Django Admin中运行。 I am working on creating a custom change form for the model it will be used in. 我正在为将使用的模型创建自定义更改表单。
The problem I am having is that after making the selection in the first selection box, nothing happens with the second box. 我遇到的问题是,在第一个选择框中进行选择后,第二个框什么也没有发生。 I have tried using both prototype and jquery, but it seems that it doesn't get to either of them. 我曾尝试使用原型和jquery,但似乎都无法使用它们。
One thing I had to do to even get it to call the function in ajax.py, is I had to add quotes around the Dajax.process variable being passed within onchange. 为了使它能够调用ajax.py中的函数,我必须要做的一件事就是我必须在onchange中传递的Dajax.process变量周围添加引号。
I am currently just using the django dev server for testing purposes. 我目前仅将django开发服务器用于测试目的。
What am I missing? 我想念什么?
So, there are several things you'll need to make work together in order to do this: 因此,您需要一起做几件事才能做到这一点:
At minimum: 至少:
Possibly: 可能:
From there, you can use FireBug or Fiddler to make sure you're passing in, and getting back the right values from your Ajax call. 从那里,您可以使用FireBug或Fiddler来确保传入,并从Ajax调用中获取正确的值。
You'll also need to handle editing a record, where you'll need to fire an Ajax call to populate your dynamic form based on the existing value of the object. 您还需要处理一条记录,在该记录中,您需要触发Ajax调用以根据对象的现有值填充动态表单。
Happy coding! 编码愉快!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.