Oscar root url

36 views
Skip to first unread message

Yahiba

unread,
Jan 21, 2020, 6:46:32 AM1/21/20
to django-oscar
Hello,

I would like to display an index page at the root url. ( www.site.com)
However the root url is redirected to catalogue ( www.site.com/catalogue)

I created an urlpattern for this like so(yellow marked) in the main projec folder urls.py file:

urlpatterns = [



    url(r'^$', views.home, name ='home'),


    path('bem-estar/', include('myblog.urls')),
    path('ckeditor/', include('ckeditor_uploader.urls')),
    path('i18n/', include('django.conf.urls.i18n')),  # > Django-2.0
    path('admin/', admin.site.urls),  # > Django-2.0

    path('', include(apps.get_app_config('oscar').urls[0])),  # > Django-2.0


    url(r'^sitemap\.xml$', views.index,
        {'sitemaps': base_sitemaps}),
    url(r'^sitemap-(?P<section>.+)\.xml$', views.sitemap,
        {'sitemaps': base_sitemaps},
        name='django.contrib.sitemaps.views.sitemap'),



]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)


but I am getting this error:


url(r'^$', views.home, name ='home'),
AttributeError: module 'django.contrib.sitemaps.views' has no attribute 'home'

what could be happening?

Samir Shah

unread,
Jan 21, 2020, 7:57:11 AM1/21/20
to django-oscar
You appear to have imported `django.contrib.sitemap.views` at the top of the file, and there is no `home` view there.  Where is your `home` view defined? You need to import it from where it's defined.

Yahiba

unread,
Jan 21, 2020, 9:37:26 AM1/21/20
to django-oscar
Hello Samir, 

Thank you for noticing, so I did the following:

from Store import views
urlpatterns += [
    url(r'^$', views.home, name ='home'),
    ...

]


but when I access www.site.com I am still redirected to www.site.com/catalogue

Yahiba

unread,
Jan 21, 2020, 9:45:28 AM1/21/20
to django-oscar
I got it working:

from Store import views
urlpatterns = [
    url(r'^$', views.home, name ='home'),
    ...

]

from django.contrib.sitemaps import views

urlpatterns += [



    path('store/', include('Store.urls')),

    path('bem-estar/', include('myblog.urls')),
    path('ckeditor/', include('ckeditor_uploader.urls')),
    path('i18n/', include('django.conf.urls.i18n')),  # > Django-2.0
    path('admin/', admin.site.urls),  # > Django-2.0

    path('', include(apps.get_app_config('oscar').urls[0])),  # > Django-2.0


    url(r'^sitemap\.xml$', views.index,
        {'sitemaps': base_sitemaps}),
    url(r'^sitemap-(?P<section>.+)\.xml$', views.sitemap,
        {'sitemaps': base_sitemaps},
        name='django.contrib.sitemaps.views.sitemap'),



]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I got this working by changing the order of the url patterns


thanks
Reply all
Reply to author
Forward
0 new messages