Slide 1

Slide 1 text

PYCON UK 2014 FIRST STEPS WITH DJANGO CMS by Iacopo Spalletti @yakkys

Slide 2

Slide 2 text

WHO AM I? Founder and Lead developer @NephilaIt django CMS core developer django CMS installer author

Slide 3

Slide 3 text

DJANGO CMS FIRST LOOK BRIEF OVERVIEW OF DJANGO CMS FEATURES FEEL FREE TO COME TO THE BOOTH OR AT THE SPRINTS FOR MORE

Slide 4

Slide 4 text

WHAT'S DJANGO CMS? 'JUST' A CMS FOR DJANGO (APPARENTLY) With a twist!

Slide 5

Slide 5 text

DJANGO CMS HOW IS DIFFERENT? IT'S LIMITED (BY DESIGN) YOU CANNOT "EXTEND" A PAGE

Slide 6

Slide 6 text

DJANGO CMS WHY IS THAT? WHY NOT? WE HAVE DJANGO MODELS! GOOD DJANGO CITIZEN

Slide 7

Slide 7 text

DJANGO CMS CONTRIBUTING FEATURES django CMS provides features that your applications can use

Slide 8

Slide 8 text

BASIC CONCEPTS PAGE PLACEHOLDER PLUGIN APPHOOK FRONTEND EDITOR

Slide 9

Slide 9 text

LIVES IN A LIVE AND DRAFT VERSION DEFINED BY THE TEMPLATE APPLIED TO IT PAGE THE BUILDING BLOCK OF THE CMS

Slide 10

Slide 10 text

PLACEHOLDER ACTIVE AREAS WITHIN YOUR PAGES PLUGIN CONTAINERS DEFINED IN THE TEMPLATES JUST A TEMPLATETAG

Slide 11

Slide 11 text

PLACEHOLDER HOW TO DEFINE A PLACEHOLDER? {% placeholder "first_placeholder" %}

Slide 12

Slide 12 text

PLACEHOLDER THERE IS MORE class MyModel(models.Model): name = models.CharField(max_length=200) abstract = models.TextField() content = PlaceholderField() Composition, not inheritance

Slide 13

Slide 13 text

PLUGIN Placeholder = Container Plugin = Content

Slide 14

Slide 14 text

PLUGIN WHAT'S A PLUGIN? A content A bridge towards other Django applications

Slide 15

Slide 15 text

PLUGIN WRITING PLUGIN IS EASY class MyPlugin(CMSPluginBase): name = _('My plugin') render_template = 'myapp/myplugin.html'

Slide 16

Slide 16 text

PLUGIN 1. PLUGIN CLASS class MyPlugin(CMSPluginBase): name = _('My plugin') model = MyPluginModel render_template = 'myapp/myplugin.html' def render(self, context, instance, placeholder): newslist = News.objects.all().order_by('-date') context.update({ 'instance': instance, 'news_list': newslist[:instance.posts] }) return context Plugin = ModelAdmin + template + get_context_data

Slide 17

Slide 17 text

PLUGIN 2. THE PLUGIN MODEL It's the plugin conīŦguration class MyPluginModel(CMSPlugin): title = models.CharField(max_length=200) posts = models.PositiveIntegerField()

Slide 18

Slide 18 text

PLUGIN 3. THE TEMPLATE Template is a standard Django template fragment to which the plugin generated context is provided

{{ instance.title }}

{% for news in news_list %} {{ news.title }}
{% endfor %}

Slide 19

Slide 19 text

APPHOOK Is a bridge between the CMS and other Django applications In rough terms, it appends the application URLConf to the page tree

Slide 20

Slide 20 text

It wraps the URLCon in a class APPHOOK SOME CODE class MyApp(CMSApp): name = _("My App") urls = ["apps.my_app.urls"] menus = [MyMenu] apphook_pool.register(MyApp)

Slide 21

Slide 21 text

APPHOOK THAT'S ALL :)

Slide 22

Slide 22 text

FRONTEND EDITOR WARNING! IT'S ADDICTIVE!

Slide 23

Slide 23 text

FRONTEND EDITOR WHAT'S IT? NEW IN DJANGO CMS 3 ADMIN OUTSIDE THE ADMIN

Slide 24

Slide 24 text

FRONTEND EDITOR FOLLOW THE WHITE PONY

Slide 25

Slide 25 text

FRONTEND EDITOR TOOLBAR COMPLETE SIMPLE DYNAMIC CUSTOMIZABLE

Slide 26

Slide 26 text

FRONTEND EDITOR ANCHE NEI VOSTRI MODEL EVERY MODEL CAN BE FRONTEND-ENABLED {% render_model instance "abstract" %} {% render_model_block instance %}

{{ instance.title }}

{{ instance.date }}
{% endrender_model_block %}

Slide 27

Slide 27 text

SHAMELESS PLUG!

Slide 28

Slide 28 text

GRAZIE! SEE YOU TOMORROW! DJANGO CMS SPRINT And tips and support to use django CMS Iacopo Spalletti [email protected] @yakkys