Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Inside Mezzanine

Steve
October 29, 2015

Inside Mezzanine

For SyDjango Oct 2015 I presented a talk on the core features of Mezzanine and how they're implemented using Django. The aim was to demonstrate the simplicity of Mezzanine, and show the audience how they could build their own CMS using Django.

Steve

October 29, 2015
Tweet

More Decks by Steve

Other Decks in Programming

Transcript

  1. >

  2. class Page(models.Model): title = models.CharField("Title") slug = models.CharField("URL") parent =

    models.ForeignKey("Page", related_name="children", null=True) order = models.IntegerField("Order") content_model = models.CharField( editable=False)
  3. {% page_menu %} pages = {} for page in Page.objects.all():

    parent_id = page.parent_id if parent_id not in pages: pages[parent_id] = [] pages[parent_id].append(page) def show_branch(parent_id, depth=0): for page in pages[parent_id]: print (" " * depth) + page.title if page.id in pages: show_branch(page.id, depth + 1)
  4. class Page(models.Model): def save(self, *args, **kwargs): self.slug = slugify(self.title) self.content_model

    = self._meta.object_name super(Page, self).save(*args, **kwargs) def get_content_model(self): return getattr(self, self.content_model) @staticmethod def get_content_models(): return [m for m in get_models() if m is not Page and issubclass(m, Page)]
  5. mezzanine.conf.settings register_setting( name="ACCOUNTS_APPROVAL_REQUIRED", label="New accounts require approval?", editable=True, default=False, )

    register_setting( name="ACCOUNTS_APPROVAL_EMAILS", label="Account approval email addresses", editable=True, default="", )
  6. Batteries Included: - Keywords, ratings, threaded comments - Search -

    Multi-lingual content - Accounts, registration, profiles - Multi-tenancy - Image thumbnailing - Caching - Bootstrap + live editing - Deployment tooling - Ecommerce: cartridge.jupo.org - Forum: drum.jupo.org - Themes: mezzathe.me ~ 70 Packages: bit.ly/MezzPackages