0

So I've been working on a project and I need 2 apps for it. I've made one of them from scratch and I am using Oscar(an e-commerce app). I have both the Apps in my Installed_Apps. But after installing oscar, I'm unable to visit the urls of my other app.

settings.py

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

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(__file__)
location = lambda x: os.path.join(
    os.path.dirname(os.path.realpath(__file__)), x)

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

# 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.sites',
    'django.contrib.flatpages',
    'NGO',
    'compressor',
    'widget_tweaks',

] + get_core_apps()

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'oscar.apps.basket.middleware.BasketMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

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

HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
}

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

ROOT_URLCONF = 'codeshastra.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.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 = 'codeshastra.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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

STATIC_URL = '/static/'
STATIC_ROOT = location('public/static')

urls.py

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

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),

url(r'^$', views.testview),
url(r'^allschools/$', views.allSchools, name = 'allSchools'), 
url(r'^98761234([A-z]+)/$', views.studentsOfSchool, name = 'studentsOfSchool'),
url(r'^incrementdayspresent/(\d+)/98761234([A-z]+)/$', views.incrementDaysPresent),
url(r'^incrementtotaldays/(\d+)/98761234([A-z]+)/$', views.incrementTotalDays),
url(r'^addnewschool/$', views.addNewSchool, name = "addnewschool"),
url(r'^addnewstudent/$', views.addNewStudent, name = "addnewstudent"),
url(r'^searchstudent/$', views.searchStudent, name = "searchStudent"),
url(r'^searchSchool/$', views.searchSchool, name = "searchSchool"),
url(r'^average(\d+)/$', views.marksheet, name = "marksheet"),
url(r'^addmarks/(\d+)/$', views.addMarks, name = "addMarks"),
url(r'^98761234[A-z]+/(\d+)/$', views.StudentProfile, name ="Profile"),
url (r'^accounts/login/$', views.loginUser, name = "Auth"),

url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'', include(application.urls)),

]

Now, if I visit the "/allschools/" or any of the other urls all I can see is a blank page with Oscar as the page title. Does anyone know why this is happening?

Sayse
  • 42,633
  • 14
  • 77
  • 146
Avais
  • 169
  • 1
  • 1
  • 9
  • What's your templates structure? Are you extending `oscar` templates? i.e. base.html and layout.html from oscar. – kaveh Jan 23 '16 at 23:50
  • @kaveh 's observations should be considered, and since you're still running in debug mode, you should have your static files urls included in the urlconf `urlpatterns = [ ... ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)` – Moses Koledoye Jan 24 '16 at 00:02
  • @kaveh no I'm not extending base.html from oscar. – Avais Jan 24 '16 at 00:25
  • @MosesKoledoye appending static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) tp my urlpatterns gives me an error "name 'static' is not defined" – Avais Jan 24 '16 at 00:25
  • you are missing imports `from django.conf import settings`, `from django.conf.urls.static import static`. Be sure to have set STATIC_URL and STATIC_ROOT in your settings – Moses Koledoye Jan 24 '16 at 00:33
  • @MosesKoledoye After importing, I'm still getting the same error, i.e a blank screen with oscar as the title. – Avais Jan 24 '16 at 00:42
  • 1
    @MosesKoledoye The `staticfiles` contrib app patches `runserver` to serve static files while in debug mode. If you use `staticfiles` you only need `+ static()` for media files. – knbk Jan 24 '16 at 00:55
  • On a second thought, try running without the oscar MW to be sure the problem isn't a config problem. – Moses Koledoye Jan 24 '16 at 01:56
  • I have tried it without Oscar. It works perfectly. – Avais Jan 24 '16 at 02:59

0 Answers0