[英]404 when call Dajaxice function cause of WSGI Alias
我將組合框轉換為可以使用Dajaxice動態刷新的表單,我在開發中沒有問題,但是在WSGI的生產中卻遇到以下問題:
用於項目的VirtualHost具有用於加載Web應用程序的別名WSGIScriptAlias /dgp /path/to/wsgi
,所有路由都在此子站點下構造,但Dajaxice則不是,其URL必須為http://example.com/dgp/dajaxice/ventas.updatecomboproducto/
而不是http://example.com/dajaxice/ventas.updatecomboproducto/
,在那里顯然找不到任何東西,所以我不知道如何告訴Dajaxice注意到wsgi別名,我嘗試使用DAJAXICE_MEDIA_PREFIX='dgp'
但僅在子DAJAXICE_MEDIA_PREFIX='dgp'
下有效,這意味着只能與http://desarrollorivas.no-ip.org/dgp/dgp/dajaxice/ventas.updatecomboproducto/
,但無法解決任何問題。
有任何想法嗎? 這是代碼,在categoria
中,這是我調用Dajaxice進程並加載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)
問候!
該代碼應考慮到應用程序的URL掛載點可能不是通過使用適當的函數來構造包含該掛載點的URL的網站根源。 請參閱以下文檔:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.