Simplecms. This is the CMS framework used by the web consultancy company Return to the Source, provided here for everyone to use under the AGPL license as part of our free and open source philosophy.
 
 
 
 
Go to file
Jaap Joris Vens 1e503349d6 Minor tweaks 2020-03-22 21:19:12 +01:00
cms Minor tweaks 2020-03-22 21:19:12 +01:00
example Minor tweaks 2020-03-22 21:19:12 +01:00
.gitignore
LICENSE
MANIFEST.in
README.md Minor tweaks 2020-03-22 21:19:12 +01:00
manage.py The dependency on swapper has been replaced with an incredibly simply 2020-03-22 12:46:10 +01:00
setup.py Tidying up! 2020-03-22 19:57:48 +01:00

README.md

Django Simple CMS

A super simple but very extensible content management system for Django websites.

SimpleCMS provides the reusable Django app cms which contains everything you need to create websites that can be easily edited by end users.

How does it work?

Contrary to 'regular' Django websites, SimpleCMS allows you to write a view for each section, rather than for each page on your website. On which pages these sections appear, and in which order, is left to the content editor rather than the programmer. After authenticating, the user can use the "Edit" interface to fill the website with various types of content.

Here's an example views.py of an app using SimpleCMS:

from cms.views import SectionView
from cms.decorators import section_view

@section_view
class HelloWorld(SectionView):
    verbose_name = 'Hello world section'
    fields = ['content']
    template_name = 'hello.html'

    def get_context_data(self, **kwargs):
        context = super()get_context_data(**kwargs)
        context['message'] = 'Hello World!'
        return context

And here is the contents of hello.html:

<section type="helloworld">
  <h1>{{message}}</h1>
  {{section.content}}
</section>

Everytime a section needs to be rendered, SimpleCMS will call the appropriate section view and insert the rendered result into the final rendered page.

But that's not all! SimpleCMS is easily extendable. You can add custom fields to your Page and Section models. You can even add one-to-many fields by defining new models with a foreign key to the Section model, and the Edit interface will automagically show the user nested formsets to edit the related instances! For a complete example see the included example app.

The "Edit" Interface

Somewhat like the Django Admin site, SimpleCMS comes with its own editing environment, albeit much simpler and only suitable for editing pages and sections. After authenticating, the content editor can click the "edit" button on any page of the website to alter, add or rearrange sections.

For each section, the section type can be selected from a dropdown menu. As you can see in views.py above, each section type comes with its own list of editable fields. Client-side javascript will hide/show the relevant fields based on the selected section type. All sections are stored in the same database table.

Batteries included!

SimpleCMS has been specifically crafted to fit our own personal needs when building websites for customers. Therefore it includes a variety of useful template tags, default Page and Section models, and all the other boilerplate code needed for new projects.

One notable inclusion is the eval template tag. It will pass its argument first through Django's templating system and then through Markdown, making for instance the following possible. (Disclaimer: use with caution!)

Welcome to **{% now 'Y' %}!**

Another useful feature is the automatic compilation of SCSS files to CSS files using a custom middleware.

Installation

Use the provided helper command simplecms to quickly setup a new project:

$ pip install https://github.com/rtts/django-simplecms.git
$ simplecms mysite

After the project files have been created, initialize the database and create a superuser:

$ cd mysite
$ sudo su postgres -c "createuser mysite; createdb -O mysite mysite"
$ ./manage.py migrate
$ ./manage.py createsuperuser

Finally, run the development server and visit http://localhost:8000/login/ in your browser to log in!

$ ./manage.py runserver

Getting help or contributing

We'd love to hear from you! If you have any questions or contributions, don't hesitate to contact us at info@returntothesource.nl