python - Pointing Django to Different Template Directory -


i building django ecommerce site based on django-oscar. default latter comes basic bootstrap theme , styles.

i moved these template files

project_root/templates/oscar

it understanding if override these templates, override original oscar templates located in virtualenv.

the next step downloaded different theme use site.

in particular, theme reside in

project_root/templates/main_theme

the trouble cannot seem django pickup templates directory. if delete project_root/templates/oscar, appears resort default oscar templates.

if place base.html project_root/templates/ , make base.html main file of new theme, displayed. however, still break smaller files , have them "live" in separate directory. how can accomplish this? there more prudent way of going this?

here relevant settings:

installed_apps = [     'django.contrib.admin',     'django.contrib.auth',     'django.contrib.contenttypes',     'django.contrib.sessions',     'django.contrib.messages',     'django.contrib.staticfiles',     'django.contrib.flatpages',     'django.contrib.sites',      'compressor',     'widget_tweaks', ] + get_core_apps()  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',             ],         },     }, ]  compress_root = os.path.join(base_dir, "static")  static_url = '/static/'  #static_root = os.path.join(base_dir, "static")  #this should commented out in development staticfiles_dirs = [   os.path.join(base_dir, "static"), ]  media_url = "/media/"  media_root = os.path.join(base_dir, "media") 

the following code worked me. turned out, 1 needed specify additional entry in dir list of templates list.

templates = [     {         'backend': 'django.template.backends.django.djangotemplates',         'dirs': [             os.path.join(base_dir, 'templates'),              #re-route search templates custom template directory             os.path.join(os.path.join(base_dir, 'templates'), 'tshirt-theme'),              #uncomment line below restore original oscar template             #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',             ],         },     }, ] 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -