Reputation: 2040
I have a complete skeleton of a website in Bootstrap 3. I am very new to Django (not to Python though). I want to integrate this particular theme and build the backend using Django. I cannot find any website for instructions on this. How can this be done? Any help is appreciated.
Upvotes: 0
Views: 797
Reputation: 3386
You just need to prepare your templates that you do usually.In your settings file, make the following changes.
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_BASE_PATH, 'templates').replace('\\', '/'),
)
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
STATIC_URL = '/static/'
MEDIA_URL = 'media/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
)
TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
)
Change your urls.py file to include the urls for static files. Like this:
urlpatterns = patterns('',
url(r'^$',LandingPage.as_view(),name='home'),)+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Place your templates in a templates folder inside your app/project and all the css, js and images inside static folder. Be sure to to include {{STATIC_URL}} before all css,js and image urls inside all the templates. Something like this:
<script src="{{STATIC_URL}}js/jquery.js"></script>
For more information on handling templates in django, try this
Upvotes: 2
Reputation: 5276
It's easier than you think :)
Look at the template syntax and how to serve static files (css, js), and you can reuse what you have aldready done
also, look at the django tutorials
Upvotes: 1