[Django]-How to add a new view to django-oscar

3👍

If it’s just the index view you want to override, then it may be easier just to insert a URL pattern in from of Oscar’s patterns:

urlpatterns = [
    path('i18n/', include('django.conf.urls.i18n')),
    path('', IndexView.as_view()),
    url(r'^', include(apps.get_app_config('oscar').urls[0])),
]

This will cause your IndexView to match ahead of Oscar’s.

Alternatively, you need to override the catalogue app where the home page view is defined. In your question you have forked the offer app, which doesn’t contain that view and hence you changes have no effect. If you take that approach then the correct way to override the view is to set self.catalogue_view in the ready() method of the app, rather than adding a new URL pattern:

class CatalogueConfig(CoreCatalogueConfig):
    def ready(self):
        super().ready()
        # This is all - you don't need to mess with the URLs.
        self.catalogue_view = IndexView

0👍

index is in :
oscar/apps/catalogue/apps.py

you have to fork catalogue

Leave a comment