DjangoCMS
Qu'est-ce ? Pourquoi ? Pour qui ? Comment ? D'où viens-je ? Où vais-je ? Qu'est-ce que je fous là ?
DjangoCMS c'est
une interface pour gérer des pages

DjangoCMS c'est
une interface d'édition frontend

DjangoCMS c'est
un CMS qui suit la philosophie Django

DjangoCMS c'est
une app comme une autre*
INSTALLED_APPS = [
'django.contrib.admin',
'cms',
]
* avec un tout petit peu de magie
DjangoCMS c'est
multilingue par défaut
LANGUAGES = (
('en', _('English')),
('fr', _('French')),
)
DjangoCMS c'est
un « marketplace » qui va avec

DjangoCMS c'est
-
compatible avec Python 3
-
bientôt compatible avec Django 1.11
🦄
DjangoCMS c'est pas
Aussi populaire que les CMS PHP*
* mais c'est peut-être mieux comme ça
Drupal
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
*clic*
clear cache
clear cache
clear cache
clear cache
clear cache
>>> drupal + sylvain TypeError: unsupported operand type(s) for +: 'cms' and 'developer'
Séparation
code | données
Templates
Placeholders
Plugins
Pages
Données de plugins
DjangoCMS c'est pas
Incroyablement rapide*
* tout est relatif
Enough bullshit, show me the code


Placeholder

Placeholder

Placeholder

Plugin
Plugin
Plugin
Plugin
Notre premier plugin
templates/base.html
{% load cms_tags %}
<!doctype html>
<html>
<body>
<header>
<div class="header-top">{% static_placeholder "header_top" %}</div>
<div class="header-bottom">{% static_placeholder "header_bottom" %}</div>
</header>
<div class="main-content">{% placeholder "main_content" %}</div>
</body>
</html>
from django.db import models
from cms.models import CMSPlugin
class ColorBox(CMSPlugin):
COLOR_CHOICES = (
('lime', 'Lime'),
('green', 'Green'),
('yellow', 'Yellow'),
('orange', 'Orange'),
)
color = models.CharField(choices=COLOR_CHOICES, max_length=20)
title = models.CharField(max_length=255)
body = models.TextField()
def __str__(self):
return self.title
Notre premier plugin
models.py
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from .models import ColorBox
class ColorBoxPlugin(CMSPluginBase):
model = ColorBox
module = "Cruncher"
name = "Color box"
render_template = "cruncher_core/color_box.html"
plugin_pool.register_plugin(ColorBoxPlugin)
Notre premier plugin
cms_plugins.py
<div class="block {{ instance.color }}-block">
<h2>{{ instance.title }}</h2>
<p>{{ instance.body }}</p>
</div>
Notre premier plugin
cruncher_core/color_box.html
Notre premier plugin
./manage.py runserver
DjangoCMS ce sera
-
une API REST pour une utilisation headless
-
un support pour des menus multiples
-
des améliorations au niveau de l'accessibilité
-
des améliorations pour la modération et les permissions
Vous avez des questions ?
DjangoCMS
By Sylvain Roflmao
DjangoCMS
- 149