I don't think I fully grasp the django-oscar documentation. I am trying to add a new view, a home view at /
of the site. But whatever I seem to do it keeps going to /catalogue/
when I want to access /
instead.
it says I should do the following:
from oscar.apps.offer.apps import OfferConfig as CoreOfferConfig
from .views import IndexView
from django.conf.urls import url
class OfferConfig(CoreOfferConfig):
def ready(self):
super().ready()
self.index_view = IndexView
def get_urls(self):
urls = super().get_urls()
urls += [
url(r'^$', self.index_view.as_view(), name='index'),
]
return self.post_process_urls(urls)
and this is in myproject/myapp/offer/apps.py
. myapp
was created following the django-oscar tutorial which involved running the command ./manage.py oscar_fork_app order myapp
.
general breakdown of the folder:
myproject:
- myproject
- settings.py
...
- static
- myapp
- order
- offer
- apps.py
- __init.py
- templates
manage.py
my urls.py in myproject
looks as follows:
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
from django.conf.urls.static import static
from django.conf import settings
from django.apps import apps
urlpatterns = [
path('i18n/', include('django.conf.urls.i18n')),
url(r'^', include(apps.get_app_config('oscar').urls[0])),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
the view I am trying to add is very very basic at the moment:
from django.views.generic import TemplateView
class IndexView(TemplateView):
template_name = "pages/index.html"
def get_context_data(self, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs)
products = ['empy', 'for', 'now']
context.update({
'products': products,
})
return context
what am I doing wrong?
I am using django-oscar 2.0.4
,django 2.2.12
, python 3.7.4