I can't start Django Oscar after installing

474 views
Skip to first unread message

michf...@gmail.com

unread,
Apr 27, 2018, 12:20:42 PM4/27/18
to django-oscar

I finally installed django oscar and I can run the server, but I don't know how to start building my page. Moreover, I don't know what url would be my home or index, I tried to enter to http://127.0.0.1:8000 and I got the following error:


VariableDoesNotExist at /

Failed lookup for key [basket] in "<WSGIRequest: GET '/'>"
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.11.12
Exception Type: VariableDoesNotExist
Exception Value:
Failed lookup for key [basket] in "<WSGIRequest: GET '/'>"
Exception Location: /home/scripts/oscar/shop/lib/python3.6/site-packages/django/template/base.py in _resolve_lookup, line 903
Python Executable: /home/scripts/oscar/shop/bin/python
Python Version: 3.6.3


Error during template rendering

In template /home/scripts/oscar/shop/lib/python3.6/site-packages/oscar/templates/oscar/partials/mini_basket.html, error at line 9



1 {% load currency_filters %}
2 {% load i18n %}
3
4 <div class="basket-mini pull-right hidden-xs">
5 <strong>{% trans "Basket total:" %}</strong>
6 {% if request.basket.is_tax_known %}
7 {{ request.basket.total_incl_tax|currency:request.basket.currency }}
8 {% else %}
9 {{ request.basket.total_excl_tax|currency:request.basket.currency }}
10 {% endif %}
11
12 <span class="btn-group">
13 <a class="btn btn-default" href="{% url 'basket:summary' %}">{% trans "View basket" %}</a>
14 <button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
15 <span class="caret"></span>
16 </button>
17 <ul class="dropdown-menu pull-right">
18 <li>{% include "basket/partials/basket_quick.html" %}</li>
19 </ul>



When I made a new category, I tried to enter to the urld and got the following error:


Page not found (404)

Request Method: GET
Request URL: http://127.0.0.1:8000/test/pruebal/

Using the URLconf defined in frobshop.urls, Django tried these URL patterns, in this order:

  1. ^i18n/
  2. ^admin/
  3. ^catalogue/
  4. ^basket/
  5.  ^checkout/
  6. ^accounts/
  7. ^search/
  8. ^dashboard/
  9.  ^offers/
  10. ^password-reset/$ [name='password-reset']
  11. ^password-reset/done/$ [name='password-reset-done']
  12. ^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$ [name='password-reset-confirm']
  13. ^password-reset/complete/$ [name='password-reset-complete']
  14. page-redirect/(?P<page_promotion_id>\d+)/$ [name='page-click']
  15. keyword-redirect/(?P<keyword_promotion_id>\d+)/$ [name='keyword-click']
  16. ^$ [name='home']

The current path, test/pruebal/, didn't match any of these.


Next, my urls.py and settings.py to understand my problem:


My urls.py:


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

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


My settings.py


import os
from oscar.defaults import *
from oscar import OSCAR_MAIN_TEMPLATE_DIR
from oscar import get_core_apps

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'u4qr6u*af63b3t#+0dkxar@cx4ok8dx4wu4&o_p@$!8nlh8mdg'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'compressor',
'widget_tweaks',
'django.contrib.sites',
] + get_core_apps()

SITE_ID = 1

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'frobshop.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
OSCAR_MAIN_TEMPLATE_DIR
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.i18n',
'django.contrib.messages.context_processors.messages',

'oscar.apps.search.context_processors.search_form',
'oscar.apps.promotions.context_processors.promotions',
'oscar.apps.checkout.context_processors.checkout',
'oscar.apps.customer.notifications.context_processors.notifications',
'oscar.core.context_processors.metadata',
],
},
},
]

WSGI_APPLICATION = 'frobshop.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'db.sqlite3',
'USER': '',
'PASSWORD': '',
'HOST': '',
'PORT': '',
'ATOMIC_REQUESTS': True,
}
}


# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

AUTHENTICATION_BACKENDS = (
'oscar.apps.customer.auth_backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)

OSCAR_INITIAL_ORDER_STATUS = 'Pending'
OSCAR_INITIAL_LINE_STATUS = 'Pending'
OSCAR_ORDER_STATUS_PIPELINE = {
'Pending': ('Being processed', 'Cancelled',),
'Being processed': ('Processed', 'Cancelled',),
'Cancelled': (),
}


HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8000/solr/',
'INCLUDE_SPELLING': True,
},
}

# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/

STATIC_ROOT = 'static'
STATIC_URL = '/static/'
MEDIA_ROOT = 'media'
MEDIA_URL = '/media/'


If do you need more information please ask me.

Samir Shah

unread,
Apr 28, 2018, 12:09:50 AM4/28/18
to django-oscar
You are missing Oscar's basket middleware from your MIDDLEWARE setting:

'oscar.apps.basket.middleware.BasketMiddleware',


data.ana...@gmail.com

unread,
Aug 19, 2018, 12:51:46 PM8/19/18
to django-oscar
HI Samir, 

I have the basket and it's still not rendering the admin site. 
everything else is fine and functional. 

SammyJ

unread,
Aug 20, 2018, 1:58:46 AM8/20/18
to django-oscar
Hi,
I think your oscar templates aren't rendering. Did you make sure you have copied all the templates from core oscar,  all templates would be under your Virtual environment you created, the path should be <virtualenv_name>/lib/python3.6/site-packages/oscar/templates/oscar/,  copy all the folders and files you find here to your local project's templates/ folder then try running 127.0.0.1:8000/ . The page that you would see comes under templates/promotions/home.html.

Damjan Stefanovski

unread,
Aug 20, 2018, 8:37:10 AM8/20/18
to django...@googlegroups.com
Good morning and thanks for the reply 
This is the Django admin panel we are talking about right ? Because the dashboard from Oscar is working fine , I’m only not able to use the original Django admin, yesterday I read the Oscar documentation and they’ve created this dashboard in order to be used instead of the admin site. 
That’s why there is not template for this . 
I’m sorting it out slowly. So if you have any suggestion let me know . 
P.s: I’ve got all the templates as you wrote below. 

--
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.
To view this discussion on the web, visit https://groups.google.com/d/msgid/django-oscar/9e093d7d-be1d-458d-95a1-2e2d3f4de32a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samir Shah

unread,
Aug 20, 2018, 9:03:58 AM8/20/18
to django-oscar
The Django admin should work if you follow the URL config outlined here: https://django-oscar.readthedocs.io/en/releases-1.6/internals/getting_started.html#urls

Oscar does not in any way modify the templates of Django's admin, so my best guess is that you just haven't configured the admin URLs correctly.

Damjan Stefanovski

unread,
Aug 20, 2018, 9:05:34 AM8/20/18
to django...@googlegroups.com
My exact opinion was that as well. 
I’ll do it again if I need to but will make it right . 
Thanks for the support . 


On Mon, Aug 20, 2018 at 9:04 AM Samir Shah <solari...@gmail.com> wrote:
The Django admin should work if you follow the URL config outlined here: https://django-oscar.readthedocs.io/en/releases-1.6/internals/getting_started.html#urls

Oscar does not in any way modify the templates of Django's admin, so my best guess is that you just haven't configured the admin URLs correctly.

--
https://github.com/django-oscar/django-oscar
http://django-oscar.readthedocs.org/en/latest/
https://twitter.com/django_oscar
---
You received this message because you are subscribed to the Google Groups "django-oscar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-oscar...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-oscar.

Damjan Stefanovski

unread,
Aug 20, 2018, 9:06:57 AM8/20/18
to django...@googlegroups.com
Also , 
I’m using Django 2.0 si path instead of url is used. 
Maybe an older Django version is better for Oscar ? 

SammyJ

unread,
Aug 21, 2018, 1:44:09 AM8/21/18
to django-oscar
HI,
I am using Django 2.0 too,you can use either path or url, take a look at the latest documentation on the urls here: https://django-oscar.readthedocs.io/en/latest/internals/getting_started.html#urls The code for Django > 2.0 is commented out, you may un comment them and comment the codes above, the ones with url() is for Django<2.0.

Damjan Stefanovski

unread,
Aug 21, 2018, 2:50:43 PM8/21/18
to django...@googlegroups.com
Thanks Sammy 
Thanks exactly what I did by uncomenting the path and # the url 
There is another error I’m getting now as I can’t save the products from the dashboard side and add content to the site a bit. 
Not an easy task with manipulating Oscar to the needs and purposes and modifications for my site . 

Reply all
Reply to author
Forward
0 new messages