如何在Django Oscar中自定义复杂的网址模式

时间:2019-06-02 08:42:01

标签: python django e-commerce django-urls django-oscar

我已经建立了一个Django-oscar项目,并且正在尝试配置URL。我的目标是将/ checkout / shipping-address /更改为/ checkout / billing-address /

根据文档,我已经在myproject / app.py中添加了app.py

myproject / app.py

from django.conf.urls import url, include
from oscar import app


class MyShop(app.Shop):
    def get_urls(self):
        urls = super(MyShop, self).get_urls()
        for index, u in enumerate(urls):
            if u.regex.pattern == r'^catalogue/':
                urls[index] = url(r'^product/', include(self.catalogue_app.urls))
            elif u.regex.pattern == r'^basket/':
                urls[index] = url(r'^cart/', include(self.basket_app.urls))
            elif u.regex.pattern == r'^checkout/shipping-address/':
                urls[index] = url(r'^checkout/billing-address/', include(self.checkout_app.urls))
                break
        return urls


application = MyShop()


myproject / urls.py

from django.conf.urls import url, include
from django.contrib import admin
from . import views
from .app import application

urlpatterns = [
    url(r'^i18n/', include('django.conf.urls.i18n')),

    url(r'^admin/', admin.site.urls),

    url(r'', application.urls),

    url(r'^index/$',views.index, name = 'index'),
]

如何将Checkout / shipping-address /更改为checkout / billing-address /?

0 个答案:

没有答案