Django is a framework charming in its simplicity and flexibility. However, to quickly build a large number of simple sites, you need to put the development of sites on stream. Developing a site management system every time is tiring and threatens to waste time. That is why programmers often turn to ready-made CMS.
Almost everyone knows about the giants of conveyor web programming based on php - Drupal, Joomla !, Wordpress and others, but not everyone knows that there are equally powerful and even much more mature tools in the Python world.
')
Those who know the world of Python and are not interested in installation can go directly to the section
Small joys of CMS .
Likbez
Talking about web applications on Python should start with the dad of all CMS and frameworks: Zope. Its history stretches from shaggy 1998, the framework ("application server") includes its own database, Guido Van Rossum himself participated in the project, the framework elements and architectural solutions are used in many other large projects (primarily Zope Component Architecture).
The second most important project can be considered Plone CMS (born in 1999), based on Zope. Plone is widely known just west of the Russian Federation; around it even the mini-industry of building sites (like the one that revolves on Drupal) was formed.
Server web of the last wave
The last years were marked by three events in agile-webbuilding: MVC arrived, php became boring and Ruby was actually born anew.
Ruby on Rails, Django were announced in 2005 and put the general idea at the forefront: MVC on the web to be, MVC (or as it is called in Django) on the web to steer. On this wave, a little-known before Ruby rose and the popularization of Python in web development accelerated.
And, of course, remembering why Python and Ruby are doing php is simply not worth it.
However, Python is a universal language; interesting frameworks on it more (which only Twisted costs); the story is richer. Therefore, I personally chose Python (and, accordingly, Django) as the first auxiliary scripting language, and then, when all its rich features, and the main one, were opened.
Django + DjangoCMS2.0 - as they are
Cycling - a favorite occupation of programmers. We all want to control the development process at all levels: it leaves a lot of room for exploits and personal heroism.
But there comes a moment - and writing a blog together with a dozen static pages (flatpages, if in Jung) starts to seem something extra. In my bright moment, I decided to explore the world on the subject of CMS, based on Django.
It turned out that the choice here is the
following :
- lightpages based on flatpages
- somewhat unsightly PyLucid
- flexible feincms
- DjangoCMS with its nice site and coherent documentation
Out of the box, the greatest functionality was provided by DjangoCMS, which is why the first
It was decided to get industrial experience on it.
Installation
The latest trend in Python fashion (if not a necessity) is the use of the virtualenv environment. This is a sandbox in which all the dependencies of the future project are installed: the interpreter itself, the standard tools, the necessary libraries. In our case - Django and DjangoCMS.
Create a cms-project directory, in it - the virtualenv environment:
# all that without which normal people do not write on Python:
sudo apt-get install python-setuptools python-dev build-essential python-pip python-virtualenv
# some time passes ...
# prepare a project corner:
mkdir cms-project
cd cms-project
# create an environment in the env directory, the --no-site-packages key closes access
# environment to global system libraries
virtualenv --no-site-packages env
Now we put django, DjangoCMS and PIL (Python Imaging LIbrary), being right in
the same director (cms-project):
pip install django -E env /
# ...
pip install django-cms -E env /
# ...
pip install pil -E env /
# ...
By the way, pip is used, which is slightly better than the usual easy_install. The -E switch and its argument point to the environment directory into which the package is expanded. Now we start the environment (still being in the cms-project):
. env / bin / activate
Now we are in the environment (env), commands of Django installed in the environment are available to us:
django-admin.py startproject tstproj
We adjust,
as usual in Django , tstproj / settings.py (DB and other small
joy).
We connect the admin panel , do not forget to do it in the directory MEDIA_ROOT
simlink on its statics.
We check the work of the framework:
cd tstproj
python manage.py runserver
Now you need to connect django-cms. In general, it is
simple . You just need to add the context processors, the application itself, to create at least one template. Again, in MEDIA_ROOT - a symlink on cms statics, in settings.py - a variable with the address cms. Creating a symlink in my case (all static - in the directory tstproj / media /)
looks like that:
cd tstproj / media /
ln -s ../../env/cms/media/cms/
Voila We try:
cd tstproj
python manage.py runserver
We go to the admin panel in the browser (
http: // localhost: 8000 / admin / by default), and - oh, happiness! - get into the CMS.
Little joys CMS
So, what gives us a CMS.
In the admin interface, the item "CMS" appears with the sub-item "Pages". Here
The heart of the application is the site map tree. You can connect pages
manage their publication and inclusion in the menu.
Creating each page starts with a template. Patterns are listed in
variable CMS_TEMPLATES in the settings.py file.
The template is a regular for Django, with cms_tags tags enabled. The main tag is a placeholder that indicates where plugins are enabled. Other convenient tags, show_menu and breadcrumbs, allow you to include the navigation menu and breadcrumbs in the template. The appearance of the auxiliary elements is easily regulated in separate templates.
Places marked with the placeholder tag from the admin interface can be filled with plugins. Out of the box are available plugins to the page formatted text, links, files, images, Google Map, pieces of html.
New plug-ins are created very easily based on existing models, the content management interface of the plug-in can be generated automatically - as with regular Django models.
For a person familiar with the development on the framework it is very convenient that you can add regular Django applications to the site map - and the navigation menu will take them into account. Applications for this must be registered in settings.py:
CMS_APPLICATIONS_URLS = (
('mysite.app.urls', 'Some app'),
)
Applications can also modify the behavior of the navigation menu. For example, list catalog items, store sections, and so on.
That's all. However, I don’t need anything more.
And this is, in fact, the site map:

Magic WYSIWYG:

Editing a site page:

Conclusion
The administrator interface is simple enough and not ashamed to show the customer site.
There are not many plug-ins and extensions yet, but it will not be difficult for a web programmer to connect any of the usual Django applications or develop a new component.
It should be noted intelligible and convenient documentation.
In general, DjangoCMS2.0 is quite suitable for people who often deal with Django and are used to easy Python development.
UPD: Find project documentation, download the package, find plugins or extensions
hereUPD2: Pictures plopped from the official site at the request of hardworking programmers. Checked personally - everything looks like that.