Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nothing showing up at URL "http://localhost:8000/buy/"

I wanted to include an ecommerce portal on my website and I have done everything as given on the "Create your Shop page" as given in Django-Oscar documentation, just that in urls.py instead of

url(r'', include(application.urls)),

I have added

url(r'^buy/', include(application.urls)),

but the problem is that when I hit the url it is neither showing anything nor giving an error.

Any idea what could be the problem?

It could be some urls are clashing or something else trivial but I am not able to understand from where to start debugging.

File urls.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
from view import AboutusView, TwentySevenView
import apps.users.views
from django.conf import settings

    #oscar urls
    from oscar.app import application

    admin.site.site_header = ''
    urlpatterns = patterns('',
                           # Examples:
                           # url(r'^$', 'torquehp.views.home', name='home'),
                           # url(r'^users/', include('users.urls')),
                           url(r'^i18n/', include('django.conf.urls.i18n')),
                           url(r'^admin/', include(admin.site.urls)),
                           url(r'^about-us/$', AboutusView.as_view(), name="about-us"),
                           url(r'^24x7/$', TwentySevenView.as_view(), name="24x7"),
                           url(r'^$', apps.users.views.user_home, name="home"),
                           url(r'^markdown/', include('django_markdown.urls')),
                           url(r'^users/', include('apps.users.urls')),
                           url(r'^doorstep/', include('apps.doorstep.urls')),
                           url(r'^cars/', include('apps.cars.urls')),
                           url('', include('social.apps.django_app.urls', namespace='social')),
                           # urls for zinnia
                           url(r'^blog/', include('zinnia.urls', namespace='zinnia')),
                           url(r'^comments/', include('django_comments.urls')),
                           url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
                               {'document_root': settings.MEDIA_ROOT, }),
                           # oscar URLs
                           url(r'^buy/', include(application.urls)),
    )

File settings.py

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

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

# sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))  # to store apps in apps/ directory


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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ''

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

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.admin',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.flatpages',
    'apps.users',
    'apps.doorstep',
    'apps.cars',
    'django_markdown',
    'social.apps.django_app.default',
    'django.contrib.sites',
    'django_comments', 
    'mptt',             
    'tagging',          
    'zinnia',           
    'compressor',
    ] + get_core_apps()
# specifying the comments app
# COMMENTS_APP = 'zinnia_threaded_comments'

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',
    'oscar.apps.basket.middleware.BasketMiddleware',
    'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

# Authentication backend used by python-social-auth
AUTHENTICATION_BACKENDS = (
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.google.GoogleOAuth2',
    'django.contrib.auth.backends.ModelBackend',
    'oscar.apps.customer.auth_backends.EmailBackend',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    "social.apps.django_app.context_processors.backends",
    "social.apps.django_app.context_processors.login_redirect",
    "django.contrib.auth.context_processors.auth",
    "django.contrib.messages.context_processors.messages",
    "django.core.context_processors.i18n",
    "django.core.context_processors.request",
    "zinnia.context_processors.version",
    "django.core.context_processors.debug",
    "django.core.context_processors.media",
    "django.core.context_processors.static",
    "django.core.context_processors.tz",
    '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'
)

# TEMPLATE_LOADERS = (
#     'app_namespace.Loader',
# )

ROOT_URLCONF = 'torquehp.urls'

WSGI_APPLICATION = 'torquehp.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': "",
        'USER': '',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '3306'
    }
}

# Internationalization

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

LOGIN_URL = '/users/login/'

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

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '/static/')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
MEDIA_URL = "/media/"
TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates').replace('\\', '/'),
    location('templates'),
    OSCAR_MAIN_TEMPLATE_DIR,
)

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'staticfiles'),


)
REGISTRATION_INVALID = 50
MESSAGE_TAGS = {
    REGISTRATION_INVALID: 'InvalidDetails',
}
# temporary , should not be in settings file
SOCIAL_AUTH_FACEBOOK_KEY = ""
SOCIAL_AUTH_FACEBOOK_SECRET = ""
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']

SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ""
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ""

LOGIN_REDIRECT_URL = '/blog/'

# ------------------------------------ #
# Settings for sending email #

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# ------------------------------------ #


# site id for django sites framework
SITE_ID = 1

# configuration settings for  django-zinnia
ZINNIA_PING_EXTERNAL_URLS = False
ZINNIA_SAVE_PING_DIRECTORIES = False
ZINNIA_MARKUP_LANGUAGE = 'markdown'
ZINNIA_UPLOAD_TO = 'uploads/zinnia/'
# TimeZone Settings
USE_TZ = True

# ------------------------ #
# django s=oscar search settings
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
}

Screenshots:

http://localhost:8000/buy/ enter image description here

http://localhost:8000/buy/catalogue/

enter image description here

like image 732
ofnowhere Avatar asked May 02 '15 19:05

ofnowhere


2 Answers

I see that in your second screenshot localhost:8000/buy/catalogue/ you actually get a result. It would seem as if you haven't defined your own templates or somehow need to fix your TEMPLATE_DIRS or TEMPLATE_CONTEXT_PROCESSORS settings.

I haven't used oscar, but that fact that you get something on screen seems like a template loading issue to me.

See their docs about setting the template_context_processors

Can you post your settings please?

Update:

After seeing your settings, the template_context_processors look correct. I next looked at oscar's templates and they seem to extend without qualifying the oscar directory. For example, layout.html (/oscar/templates/oscar/layout.html) does this:

{% extends 'base.html' %}

Now, if you also have a 'base.html' file in your own project directory, say project_dir/templates/base.html, then it'll probably use that instead. Can you try to temporarily rename that file (if it exists) and see what happens?

like image 126
Esteban Avatar answered Nov 12 '22 22:11

Esteban


urls.py

url(r'^buy/', include("app.urls")),

Then under your app directory create a file called urls.py

app/urls.py

# this is your “http://localhost:8000/buy/”
url(r'^$', ViewName.as_view(), name="thename"),
like image 1
Othman Avatar answered Nov 13 '22 00:11

Othman