404当调用Dajaxice函数导致WSGI别名时

时间:2014-06-02 20:53:27

标签: python django wsgi dajaxice dajax

我将组合框放到一个用Dajaxice动态刷新的表单中,我在开发过程中没有遇到任何问题但是在生产中使用WSGI我有以下问题:

VirtualHost for project有一个别名WSGIScriptAlias /dgp /path/to/wsgi用于加载Web应用程序,所有路由都在此子网站下构建但Dajaxice没有,其中url必须是http://example.com/dgp/dajaxice/ventas.updatecomboproducto/而不是http://example.com/dajaxice/ventas.updatecomboproducto/显然找不到任何东西,所以我不知道如何告诉Dajaxice注意到wsgi别名,我尝试使用DAJAXICE_MEDIA_PREFIX='dgp',但只能在子网站下工作,这意味着,只适用于{{1}那不能解决任何问题。

有什么想法吗?这是代码,http://desarrollorivas.no-ip.org/dgp/dgp/dajaxice/ventas.updatecomboproducto/是我调用Dajaxice进程并加载url的地方:

categoria

urls.py

class DetallePedidoModelForm(forms.ModelForm):
    id = forms.IntegerField(widget=forms.HiddenInput)
    categoria = forms.ChoiceField(choices=[[0, '----------']] + [[c.id, c.nombre] for c  in Categoria.objects.all()],widget=forms.Select(
        attrs={'onchange': 'Dajaxice.ventas.updatecomboproducto(Dajax.process, {"option":this.value,"id":this.id});'}))
    #producto = forms.ChoiceField(choices=[[0, '----------']] + [[p.id, p.nombre] for p  in Producto.objects.all()],widget=forms.Select(
        #attrs={'onchange': 'Dajaxice.ventas.updatevaluecantidadproducto(Dajax.process, {"option":this.value,"id_producto":this.id});'}))
    cantidad = forms.IntegerField(widget=NumberInput(attrs={'min':'0','step':'1','style':'width: 50px;','value':'0'}))
    descuento =  forms.FloatField(widget=NumberInput(attrs={'step':'any','style':'width: 50px;','value':'0.0'}))
    pvp_manipulacion =  forms.FloatField(widget=NumberInput(attrs={'step':'any','value':'0.0'}))
    class Meta:
        model = Detalle_Pedido
        fields = ["id","categoria","producto","unidad_precio","cantidad","descuento","manipulacion","pvp_manipulacion"]

    def __init__(self,*args,**kwargs):
        super(DetallePedidoModelForm, self).__init__(*args,**kwargs)
        self.fields['categoria'].empty_label = "Selecciona una categoria"
        self.fields['producto'].widget.attrs["onchange"] = 'Dajaxice.ventas.updatevaluecantidadproducto(Dajax.process, {"option":this.value,"id_producto":this.id});'




PedidoForm = modelform_factory(Pedido, PedidoModelForm, exclude=("producto",),formfield_callback=make_custom_datefield)
DetallePedidoFormSet = modelformset_factory(Detalle_Pedido,exclude=("unidad_precio","pedido",),
                                            form=DetallePedidoModelForm)

问候!

1 个答案:

答案 0 :(得分:0)

代码应该考虑到应用程序的URL挂载点可能不在网站的根目录,方法是使用适当的函数来构造包含挂载点的URL。请参阅以下文档: