Introduction to Django CMS
-
Upload
pim-van-heuven -
Category
Internet
-
view
240 -
download
4
Transcript of Introduction to Django CMS
Why?• New Think Wize website
• Request to build a website
• Another request to build a website
• And another one …
• Django experience
Building websites• Realistic budget
• Increasing baseline demands:
• Responsive
• Components: text and images, carousel, contact form, map, analytics, newsletter, blog…
• Ability to make small edits
• Build yourself not really effective for most
Django CMS installer• https://github.com/nephila/djangocms-installer
• pip install djangocms-installer
• virtualenv projectenv
• source env/bin/activate
• mkdir project
• cd project
• djangocms -f -p . website
Versions
django CMS version (choices: 2.4, 3.0, 3.1, stable,develop) [default stable]: stable
Django version (choices: 1.4, 1.5, 1.6, 1.7, 1.8, stable) [default stable]: stable
Database configurationURLs
Database configuration (in URL format) [default sqlite://localhost/project.db]:
sqlite://localhost/project.db postgres://user:password@host:port/name mysql://user:passwordl@host:port/name
i18n / i10n
• i18n = internationalisation
• translations
• i10n = localisation
• date and number formats
Activate Django I18N / L10N setting (choices: yes, no) [default yes]: yes
Languages
Languages to enable. Option can be provided multiple times, or as a comma separated list. Only language codes supported by Django can be used here: nl, en
Optional default time zone [default Europe/Brussels]:Activate Django timezone support (choices: yes, no) [default yes]: yes
templates & placeholders
• html pages:
• base.html
• feature.html
• menu.html
• page.htmlCMS_TEMPLATES = ( ## Customize this ('page.html', 'Page'), ('feature.html', 'Page with Feature'))
page.html
{% extends "base.html" %}{% load cms_tags %}
{% block title %}{% page_attribute "page_title" %}{% endblock title %}
{% block content %} {% placeholder "content" %}{% endblock content %}
no bootstrap• templates:
• base.html
• fullwidth.html
• sidebar_left.html
• sidebar_right.html
CMS_TEMPLATES = ( ## Customize this ('fullwidth.html', 'Fullwidth'), ('sidebar_left.html', 'Sidebar Left'), ('sidebar_right.html', 'Sidebar Right'))
sidebar_left.html{% extends "base.html" %}{% load cms_tags %}
{% block title %}{% page_attribute "page_title" %}{ % endblock title %}
{% block content %} <div class="sidebar"> {% placeholder "sidebar" %} </div> <div class="content"> {% placeholder "content" %} </div>{% endblock content %}
Custom template
Use custom template set [default no]: no
(Use custom template set [default no]: ~/djangocms/defaulttemplates/)
Load a starting page with examples after installation (english language only). Choose "no" if you use a custom template set. (choices: yes, no) [default no]: yes
Plugins• Must have
• djangocms-admin-style
• djangocms-text-ckeditor
• easy_thumbnails
• django-filer
Plugins• taggit, taggit_autosuggest
• testimony
• cmsplugin_contact
• google_analytics
• image_gallery
apps.py
class CmspluginFilerImageConfig(AppConfig): name = 'cmsplugin_filer_image' verbose_name = "Image sizes"
class FilerConfig(AppConfig): name = 'filer' verbose_name = "Files and images"
aldryn_search• solr
• haystack
• manage.py build_solr_schema
• manage.py rebuild_index
• django cms apphook
cms_wizards.py
newsblog_article_wizard = NewsBlogArticleWizard( title=_(u"New news/blog article"), weight=200, form=CreateNewsBlogArticleForm, description=_(u"Create a new news/blog article."))
wizard_pool.register(newsblog_article_wizard)
templatetag
from django import templateregister = template.Library()
@register.filterdef specialplugin(field): if field in ['TextPlugin', 'FilerImagePlugin', 'LinkPlugin']: return True else: return False
templatetagtemplates/cms/toolbar/dragitem_menu.html
{% for module in module_list %} {% for p in module.list %}
{% if p.value|specialplugin %} <div class="cms-submenu-item">
<a style="background:#dff0d8" data-rel="add" href="{{ p.value }}">{{ p.name }}</a> </div>
{% endif %} {% endfor %}{% endfor %}