django-simplecms/README.md

79 wiersze
2.8 KiB
Markdown

2021-01-23 22:37:36 +00:00
![SimpleCMS](logo.gif)
2019-03-27 15:49:14 +00:00
2021-01-23 23:23:11 +00:00
**This is the CMS framework used by the web consultancy company
[Return to the Source](https://rtts.eu/), provided here for everyone
2021-01-23 23:33:26 +00:00
to use under the [AGPL](LICENSE) license as part of our free and
2021-01-23 23:35:24 +00:00
open source philosophy. Also check out our [other projects](../../../)!**
2021-01-23 23:23:11 +00:00
## Getting started
2020-03-22 18:57:48 +00:00
2021-01-23 23:23:11 +00:00
SimpleCMS provides everything to create websites that can be edited by
end users. Here's how to start a new project:
2020-03-22 18:57:48 +00:00
2021-01-23 23:23:11 +00:00
$ pip install django-simplecms
$ simplecms my_awesome_website
This will create a new directory containing a fully configured Django
project with models, views and templates. It is a renamed copy of the
included [example](example) project.
## Architecture
SimpleCMS has a rather unique take on Django's MVT architecture.
2021-01-23 23:33:26 +00:00
Contrary to "regular" Django websites, it 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 editors rather than the programmer. The included edit interface
lets them assign sections to pages and fill sections with content.
2020-03-22 18:57:48 +00:00
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):
2021-01-23 23:33:26 +00:00
context = super().get_context_data(**kwargs)
2020-03-22 18:57:48 +00:00
context['message'] = 'Hello World!'
2020-03-22 19:23:41 +00:00
return context
2020-03-22 18:57:48 +00:00
And here is the contents of `hello.html`:
<section type="helloworld">
<h1>{{ message }}</h1>
{{ section.content }}
2020-03-22 18:57:48 +00:00
</section>
2020-03-22 19:23:41 +00:00
Everytime a section needs to be rendered, SimpleCMS will call the
appropriate section view and insert the rendered result into the final
rendered page.
2020-03-22 18:57:48 +00:00
2021-01-23 23:23:11 +00:00
## The edit interface
2020-03-22 18:57:48 +00:00
Somewhat like the Django Admin site, SimpleCMS comes with its own
editing environment, albeit much simpler and only suitable for editing
2021-01-23 23:33:26 +00:00
pages and sections. After authenticating, you can click the "edit"
button on any page of the website to alter, add or rearrange sections.
2020-03-22 18:57:48 +00:00
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!
2020-07-11 17:09:01 +00:00
SimpleCMS includes a variety of useful template tags, default *Page*
and *Section* models, and all the other boilerplate code needed for
new projects.
2020-03-22 18:57:48 +00:00
2021-01-23 23:23:11 +00:00
## Feedback and support
2020-03-22 18:57:48 +00:00
2021-01-23 23:33:26 +00:00
We would love to hear from you! Feel free to [open an
issue](../../issues) or [send us an email](mailto:cms@jj.rtts.eu).