在 urlpatterns 中使用 include 时 Django 管理失败

发布于 2024-08-25 03:57:49 字数 2092 浏览 7 评论 0原文

我正在尝试稍微重构我的应用程序,以防止它变得过于笨重。因此,我开始按照文档的建议将一些 urlpatterns 移出到子文件中。

除此之外,它似乎不起作用(项目没有被重新路由),但当我去管理员处时,它说“urlpatterns 尚未定义”。

我的应用程序根目录下的 urls.py 是:

if settings.ENABLE_SSL:
urlpatterns = patterns('',
    (r'^checkout/orderform/onepage/(\w*)/$','checkout.views.one_page_orderform',{'SSL':True},'commerce.checkout.views.single_product_orderform'),
)
else:
    urlpatterns = patterns('',
    (r'^checkout/orderform/onepage/(\w*)/$','commerce.checkout.views.single_product_orderform'),
)

urlpatterns+= patterns('',
    (r'^$', 'alchemysites.views.route_to_home'),
    (r'^%s/' % settings.DAJAXICE_MEDIA_PREFIX, include('dajaxice.urls')),
    (r'^/checkout/', include('commerce.urls')),
    (r'^/offers',include('commerce.urls')),
    (r'^/order/',include('commerce.urls')),
    (r'^admin/', include(admin.site.urls)),
    (r'^accounts/login/$',  login),
    (r'^accounts/logout/$', logout),
    (r'^(?P<path>.*)/$','alchemysites.views.get_path'),
    (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}),

到目前为止,我移出的 url 是结账/优惠/订单,它们都是“commerce”的子应用程序,其中应用程序的 urls.py 非常清晰。

/urls.py 问题(包含在此处)

/commerce/urls.py 我想包含的 urls.py 是:

order_info = {
'queryset': Order.objects.all(),
}


urlpatterns+= patterns('',


(r'^offers/$','offers.views.start_offers'),
(r'^offers/([a-zA-Z0-9-]*)/order/(\d*)/add/([a-zA-Z0-9-]*)/(\w*)/next/([a-zA-Z0-9-)/$','offers.views.show_offer'),
(r'^reports/orders/$', list_detail.object_list,order_info),
)

应用程序提供的内容位于 commerce 下。

因此,额外的问题是 admin 根本无法工作,所以我在想,因为我在包含内容的某个地方杀死了它。

我检查过的事情: urlpatterns 变量是否意外在某处重置(即 urlpatterns = 模式,而不是 urlpatterns+= 模式) commerce.urls 中的模式是否有效(是的,当移回根目录时它们有效)。

所以从那里我就被难住了。我可以将所有内容移回根,但试图稍微解耦,不仅仅是出于理论原因,而且是出于一些短期原因。

最后,如果我输入 www.domainname/checkout/orderform/onepage/xxxjsd 我会得到正确的页面。但是,输入 www.domainname/checkout/ 由 alchemysites.views.get_path 处理。

如果不是答案(因为这是非常具体的),那么有没有一个好的方法来解决 urls.py 问题?这似乎只是尝试和错误。似乎应该有某种解析器来告诉你你的 urlpatterns 将做什么。

I am trying to refactor out my application a little bit to keep it from getting too unwieldily. So I started to move some of the urlpatterns out to sub files as the documentation proposes.

Besides that fact that it just doesn't seem to be working (the items are not being rerouted) but when I go to the admin, it says that 'urlpatterns has not been defined'.

The urls.py I have at the root of my application is:

if settings.ENABLE_SSL:
urlpatterns = patterns('',
    (r'^checkout/orderform/onepage/(\w*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

order_info = {
'queryset': Order.objects.all(),
}


urlpatterns+= patterns('',


(r'^offers/

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'checkout.views.one_page_orderform',{'SSL':True},'commerce.checkout.views.single_product_orderform'), ) else: urlpatterns = patterns('', (r'^checkout/orderform/onepage/(\w*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'commerce.checkout.views.single_product_orderform'), ) urlpatterns+= patterns('', (r'^

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'alchemysites.views.route_to_home'), (r'^%s/' % settings.DAJAXICE_MEDIA_PREFIX, include('dajaxice.urls')), (r'^/checkout/', include('commerce.urls')), (r'^/offers',include('commerce.urls')), (r'^/order/',include('commerce.urls')), (r'^admin/', include(admin.site.urls)), (r'^accounts/login/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, login), (r'^accounts/logout/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, logout), (r'^(?P<path>.*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'alchemysites.views.get_path'), (r'^static/(?P<path>.*)

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}),

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'offers.views.start_offers'), (r'^offers/([a-zA-Z0-9-]*)/order/(\d*)/add/([a-zA-Z0-9-]*)/(\w*)/next/([a-zA-Z0-9-)/

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'checkout.views.one_page_orderform',{'SSL':True},'commerce.checkout.views.single_product_orderform'), ) else: urlpatterns = patterns('', (r'^checkout/orderform/onepage/(\w*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'commerce.checkout.views.single_product_orderform'), ) urlpatterns+= patterns('', (r'^

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'alchemysites.views.route_to_home'), (r'^%s/' % settings.DAJAXICE_MEDIA_PREFIX, include('dajaxice.urls')), (r'^/checkout/', include('commerce.urls')), (r'^/offers',include('commerce.urls')), (r'^/order/',include('commerce.urls')), (r'^admin/', include(admin.site.urls)), (r'^accounts/login/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, login), (r'^accounts/logout/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, logout), (r'^(?P<path>.*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'alchemysites.views.get_path'), (r'^static/(?P<path>.*)

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:


and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}),

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'offers.views.show_offer'), (r'^reports/orders/

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'checkout.views.one_page_orderform',{'SSL':True},'commerce.checkout.views.single_product_orderform'), ) else: urlpatterns = patterns('', (r'^checkout/orderform/onepage/(\w*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'commerce.checkout.views.single_product_orderform'), ) urlpatterns+= patterns('', (r'^

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'alchemysites.views.route_to_home'), (r'^%s/' % settings.DAJAXICE_MEDIA_PREFIX, include('dajaxice.urls')), (r'^/checkout/', include('commerce.urls')), (r'^/offers',include('commerce.urls')), (r'^/order/',include('commerce.urls')), (r'^admin/', include(admin.site.urls)), (r'^accounts/login/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, login), (r'^accounts/logout/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, logout), (r'^(?P<path>.*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'alchemysites.views.get_path'), (r'^static/(?P<path>.*)

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}),

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, list_detail.object_list,order_info), )

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'checkout.views.one_page_orderform',{'SSL':True},'commerce.checkout.views.single_product_orderform'), ) else: urlpatterns = patterns('', (r'^checkout/orderform/onepage/(\w*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'commerce.checkout.views.single_product_orderform'), ) urlpatterns+= patterns('', (r'^

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'alchemysites.views.route_to_home'), (r'^%s/' % settings.DAJAXICE_MEDIA_PREFIX, include('dajaxice.urls')), (r'^/checkout/', include('commerce.urls')), (r'^/offers',include('commerce.urls')), (r'^/order/',include('commerce.urls')), (r'^admin/', include(admin.site.urls)), (r'^accounts/login/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, login), (r'^accounts/logout/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, logout), (r'^(?P<path>.*)/

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

,'alchemysites.views.get_path'), (r'^static/(?P<path>.*)

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

, 'django.views.static.serve', {'document_root':settings.MEDIA_ROOT}),

The urls I have moved out so far are the checkout/offers/order which are all subapps of 'commerce' where the urls.py for the apps are so to be clear.

/urls.py in questions (included here)

/commerce/urls.py where the urls.py I want to include is:

and the applications offers lies under commerce.

And so the additional problem is that admin will not work at all, so I'm thinking because I killed it somewhere with my includes.

Things I have checked for:
Is the urlpatterns variable accidentally getting reset somewhere (i.e. urlpatterns = patterns, instead of urlpatterns+= patterns)
Are the patterns in commerce.urls valid (yes, when moved back to root they work).

So from there I am stumped. I can move everything back into the root, but was trying to get a little decoupled, not just for theoretical reason but for some short terms ones.

Lastly if I enter www.domainname/checkout/orderform/onepage/xxxjsd I get the correct page. However, entering www.domainname/checkout/ gets handled by the alchemysites.views.get_path.

If not the answer (because this is pretty darn specific), then is there a good way for troubleshoot urls.py? It seems to just be trial and error. Seems there should be some sort of parser that will tell you what your urlpatterns will do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

濫情▎り 2024-09-01 03:57:49

在我的 urls.py 中添加以下行对我有用:

from django.conf.urls import include 

Adding the following line in my urls.py worked for me:

from django.conf.urls import include 
∞琼窗梦回ˉ 2024-09-01 03:57:49

查看 django 文档 包括其他 url配置文件。我想你可能误解了他们。尤其

每当 Django 遇到 include() 时,它都会截掉 URL 中与该点匹配的任何部分,并将剩余的字符串发送到包含的 URLconf 进行进一步处理。

例如,

(r'^/checkout/', include('commerce.urls')),
(r'^/offers',include('commerce.urls')),
(r'^/order/',include('commerce.urls')),

这意味着

/checkout/offers/
/offers/offers/
/order/offers/

将全部匹配 commerce/urls.py 中的网址模式 (r'^offers/$','offers.views.start_offers')代码>.

如果您想在 commerce.py 中为 /checkout/ 定义视图,则需要添加模式,

(r'^

因为 /checkout/ 部分会被 截断>include()


作为旁白:

/commerce/urls.py 中,用于

urlpatterns = patterns('',
    ...

您定义的第一个模式。然后您可以稍后在同一文件中使用 urlpatterns +=

, 'path_to_your_view')

因为 /checkout/ 部分会被 截断>include()


作为旁白:

/commerce/urls.py 中,用于

您定义的第一个模式。然后您可以稍后在同一文件中使用 urlpatterns +=

Have a look at the django docs for including other url confs. I think you might have misunderstood them. In particular

Whenever Django encounters include(), it chops off whatever part of the URL matched up to that point and sends the remaining string to the included URLconf for further processing.

As an example, you have

(r'^/checkout/', include('commerce.urls')),
(r'^/offers',include('commerce.urls')),
(r'^/order/',include('commerce.urls')),

This means that

/checkout/offers/
/offers/offers/
/order/offers/

will all match the url pattern (r'^offers/$','offers.views.start_offers') in commerce/urls.py.

If you want to define a view for /checkout/ in commerce.py, you need to add the pattern

(r'^

because the /checkout/ part will be chopped off by the include()


As, an aside:

In /commerce/urls.py, use

urlpatterns = patterns('',
    ...

for the first patterns you define. You can then use urlpatterns += later in the same file.

, 'path_to_your_view')

because the /checkout/ part will be chopped off by the include()


As, an aside:

In /commerce/urls.py, use

for the first patterns you define. You can then use urlpatterns += later in the same file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文