Enot
Enot

Reputation: 830

404 when call Dajaxice function cause of WSGI Alias

I have comboboxes into a form that refresh dynamically with Dajaxice, I have no problems in development for do this but in production with WSGI I have the follow problem:

VirtualHost for project has an alias WSGIScriptAlias /dgp /path/to/wsgi for load the web application, all routes construct under this subsite but Dajaxice don't, where the url has to be http://example.com/dgp/dajaxice/ventas.updatecomboproducto/ instead that we have http://example.com/dajaxice/ventas.updatecomboproducto/ where obviously can't find anything so I don't know how to tell Dajaxice notices the wsgi alias, I tried with DAJAXICE_MEDIA_PREFIX='dgp' but that only works under the subsite, that means, only works with http://desarrollorivas.no-ip.org/dgp/dgp/dajaxice/ventas.updatecomboproducto/ that's not resolve anything.

Any ideas? That's the code, in categoria is where I invoke the Dajaxice process and load the url:

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)

urls.py

 from django.conf.urls import patterns, include, url
 from django.conf import settings
 from django.conf.urls.static import static
 from django.contrib import admin
 from . import views
 from dajaxice.core import dajaxice_autodiscover, dajaxice_config
 dajaxice_autodiscover()

 admin.autodiscover()

 urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'dgp.views.home', name='home'),
    #url(r'^login/$', views.login,{'template_name': 'login.html'},name="my_login"),
    url(r'^login/$', 'django.contrib.auth.views.login',{'template_name': 'login.html'},name="my_login"),
    url(r'^logout/', 'django.contrib.auth.views.logout',{'template_name': 'logout.html'},name="my_logout"),
    url(r'^ventas/', include('ventas.urls', namespace="ventas")),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', include('ventas.urls')),
    url(dajaxice_config.dajaxice_url, include('dajaxice.urls')),
    )+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Regards!

Upvotes: 0

Views: 93

Answers (1)

Graham Dumpleton
Graham Dumpleton

Reputation: 58533

The code should be taking into consideration that the URL mount point of the application may not be at the root of the web site by using the appropriate functions to construct a URL which includes the mount point. See the documentation at:

Upvotes: 0

Related Questions