n | **If you want to get started with SCT quickly, ple | n | This is a simple tutorial what it needs to configu |
| ase use the ** CommunityDraft ** project instead.* | | re a simple Forum and Wiki for your website. It wa |
| *
| | lks you through creating a new project and than ad |
| | | ding the necessary confugration changes to integra |
| | | te Forum and Wiki. These should be quite the same |
| | | steps required to add it to your own website or an |
| | | existing project.
|
| | | |
| | | |
n | This describes what is needed to start a new proje | n | # Creating a new simple Django project
|
| ct from scratch which uses the Board and Wiki of S | | |
| CT.
| | |
| | | |
n | It actually contains just a couple of notes i wrot | n | You should already know how to do this, it's just |
| e down while creating the communitytools/examples/ | | a standard django setup, but i'll still walk throu |
| simpleproject - project ;) (See SimpleProject)
| | gh all steps. I am using Django 1.4 here. (Django |
| | | 1.4 has a significantly different default project |
| | | setup)
|
| | | |
n | To get a full featured website see CommunityDraft | n | ## Create a new project
|
| which should work out of the box.
| | |
| | | |
n | # Prerequisites
| n | $ django-admin.py startproject simpleproject
|
|
| | |
| Make sure you've done everything mentioned in the | | |
| INSTALLATION section of the README or on the [Docu | | |
| mentation] site.
| | |
| | | |
| | | |
n | # Creating a new project
| n | ## Configuring project to get it up and running
|
| | | |
n | Good, this was easy ;)
| n | First of all, since i don't want to commit my data |
| | | base settings into subversion i'll create a simple |
| | | project/settings_local.py and include it at the en |
| | | d of my simpleproject/settings.py:
|
| | |
|
| | | # settings_local overwrites a few settings fro |
| | | m here, and has to define SECRET_KEY
|
| | | from simpleproject.settings_local import *
|
| | | |
n | kahless@localhost ~/dev/python-new/communityto | n | my simpleproject/settings_local.py contains:
|
| ols/examples $ django-admin.py startproject simple | | |
| project
| | |
| kahless@localhost ~/dev/python-new/communityto | | |
| ols/examples $
| | |
| | | |
| | | |
n | # Configuring project to get it up and running
| n | DATABASES = {
|
| | | 'default': {
|
| | | 'ENGINE': 'django.db.backends.sqlite3' |
| | | , # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' |
| | | or 'oracle'.
|
| | | 'NAME': 'test.sqlite', |
| | | # Or path to database file if using sqlite3. |
| | |
|
| | | 'USER': '', # Not |
| | | used with sqlite3.
|
| | | 'PASSWORD': '', # Not |
| | | used with sqlite3.
|
| | | 'HOST': '', # Set |
| | | to empty string for localhost. Not used with sqli |
| | | te3.
|
| | | 'PORT': '', # Set |
| | | to empty string for default. Not used with sqlite |
| | | 3.
|
| | | }
|
| | | }
|
| | | |
n | First of all, since i don't want to commit my data | n | now you can run syncdb:
|
| base settings into subversion i'll create a settin | | |
| gs_local.py ...
| | |
| This needs two things..
| | |
| | | |
n | - add the current path to pythons lib search path
| n | Herbys-i7:simpleproject herbert$ ./manage.py s |
| | | yncdb
|
| - import all settings from the settings_local modu | | Creating tables ...
|
| le
| | |
|
| | |
| so at the end of settings.py add:
| | |
|
| | |
| import os
| | |
| ROOT_PATH = os.path.dirname(os.path.abspath(__ | | |
| file__))
| | |
| LIB_PATH = os.path.join(ROOT_PATH, '..', '..', | | |
| 'sphenecoll')
| | |
| # import directory of settings.py
| | |
| import sys
| | |
| sys.path.append(ROOT_PATH)
| | |
|
| | |
| # settings_local overwrites a few settings fro | | |
| m here, and has to define SECRET_KEY
| | |
| from settings_local import *
| | |
|
| | |
| Now simply create a settings_local.py in the same | | |
| directory and configure all DATABASE_ settings.
| | |
|
| | |
| And run syncdb:
| | |
|
| | |
| kahless@localhost ~/dev/python-new/communityto | | |
| ols/examples/simpleproject $ ./manage.py syncdb
| | |
| Creating table auth_message | | Creating table auth_permission |
| | | Creating table auth_group_permissions
|
| Creating table auth_group | | Creating table auth_group |
n | | n | Creating table auth_user_user_permissions
|
| | | Creating table auth_user_groups
|
| Creating table auth_user | | Creating table auth_user |
n | Creating table auth_permission
| n | |
| Creating table django_content_type | | Creating table django_content_type |
| Creating table django_session | | Creating table django_session |
| Creating table django_site | | Creating table django_site |
n |
| n |
|
| You just installed Django's auth system, which | | You just installed Django's auth system, which |
| means you don't have any superusers defined. | | means you don't have any superusers defined. |
| Would you like to create one now? (yes/no): ye | | Would you like to create one now? (yes/no): ye |
| s | | s |
n | Username (Leave blank to use 'kahless'): kahle | n | Username (leave blank to use 'herbert'): |
| ss | | |
| E-mail address: herbert.poul@gmail.com
| | E-mail address: a@b.com
|
| Password: | | Password: |
| Password (again): | | Password (again): |
| Superuser created successfully. | | Superuser created successfully. |
n | Installing index for auth.Message model
| n | Installing custom SQL ...
|
| Installing index for auth.Permission model
| | Installing indexes ...
|
| kahless@localhost ~/dev/python-new/communityto | | Installed 0 object(s) from 0 fixture(s)
|
| ols/examples/simpleproject $
| | |
| | | |
n | So ... your default django project should already | n | Because i am on Mac OSX i got the "ValueError: unk |
| run ....
| | nown locale: UTF-8" error, so i actually ran:
|
| | | |
n | kahless@localhost ~/dev/python-new/communityto | n | LC_CTYPE="en_US.UTF-8" ./manage.py syncdb
|
| ols/examples/simpleproject $ ./manage.py runserver | | |
|
| | |
| | |
|
| | | but i don't think this should be necessary often.. |
| | |
|
| | |
|
| | | Ok, now after our syncdb the default django projec |
| | | t should be stable and we can run it:
|
| | |
|
| | |
|
| | | Herbys-i7:simpleproject herbert$ ./manage.py r |
| | | unserver
|
| Validating models... | | Validating models... |
n | | n |
|
| 0 errors found. | | 0 errors found |
|
| | |
| Django version 0.96-pre, using settings 'simpl | | Django version 1.4b1, using settings 'simplepr |
| eproject.settings' | | oject.settings' |
| Development server is running at http://127.0. | | Development server is running at http://127.0. |
| 0.1:8000/ | | 0.1:8000/ |
| Quit the server with CONTROL-C. | | Quit the server with CONTROL-C. |
| | | |
n | Uh yeah .. not that new, is it ;)
| n | I guess this was not too exciting for anyone, sinc |
| | | e you already use django, so let's go ahead!
|
| | | |
n | # Adding 'Sphene Community Tools' Applications
| n | # Sphene Community Tools
|
| | | |
n | So now it is time to add the SCT applications. Fir | n | ## Installation
|
| st of all we need to add the python library path. | | |
| You might want to configure it in your mod_python | | |
| config, or where ever .. since i want to keep it s | | |
| imple and i actually have my project under 'commun | | |
| itytools' .. i can simply include ../../
| | |
| | | |
n | So let's add the following to settings.py right af | n | First of all you have to install SCT (the communit |
| ter were we added sys.path.append(ROOT_PATH):
| | ytools project) - you can either download it and r |
| | | un setup.py or use the GIT version from https://gi |
| | | thub.com/hpoul/sct-communitytools
|
| | | |
n | sys.path.append(LIB_PATH)
| n | I usually prefer to have the GIT version, so i che |
| | | cked it out into the same directory and added the |
| | | 'sct-communitytools/sphenecoll' path to the PYTHON |
| | | _PATH.
|
| | | |
n | Now look for your INSTALLED_APPS setting and add t | n | ## Project Configuration
|
| he default django admin application as well as the | | |
| three SCT apps .. all in all it should look like: | | |
|
| | |
| | | |
n | INSTALLED_APPS = (
| n | Add the following applications to your INSTALLED_A |
| | | PPS:
|
| 'django.contrib.auth',
| |
|
| 'django.contrib.contenttypes',
| | |
| 'django.contrib.sessions',
| | |
| 'django.contrib.sites',
| | |
|
| | |
| 'django.contrib.admin',
| | |
|
| | |
| 'sphene.community', | | 'sphene.community', |
| 'sphene.sphboard', | | 'sphene.sphboard', |
| 'sphene.sphwiki', | | 'sphene.sphwiki', |
n | )
| n | |
| | | |
n | # Adding MIDDLEWARE_CLASSES and TEMPLATE_CONTEXT_P | n | ## Adding MIDDLEWARE_CLASSES and TEMPLATE_CONTEXT_ |
| ROCESSORS | | PROCESSORS |
| | | |
n | SCT (currently) needs at least two middleware clas | n | |
| ses and two template context processor .. All in a | | |
| ll the two settings should look like the following | | |
| in your settings.py:
| | |
| | | |
n | MIDDLEWARE_CLASSES = (
| n | SCT (currently) needs at least two middleware clas |
| | | ses and one template context processor. Add the fo |
| | | llowing to middlewares to the TOP of your MIDDLEWA |
| | | RE_CLASSES:
|
| | |
|
| 'sphene.community.middleware.ThreadLocals' | | 'sphene.community.middleware.ThreadLocals' |
| , | | , |
| 'sphene.community.middleware.GroupMiddlewa | | 'sphene.community.middleware.GroupMiddlewa |
| re', | | re', |
n |
| n |
|
| 'django.middleware.common.CommonMiddleware | | To add the template context processor you need to |
| ',
| | modify TEMPLATE_CONTEXT_PROCESSOR - this variable |
| | | is by default not set in the generated settings.py |
| | | - so if you don't have it yet in your settings.py |
| | | you have to add it:
|
| 'django.contrib.sessions.middleware.Sessio | |
|
| nMiddleware',
| | |
| 'django.contrib.auth.middleware.Authentica | |
|
| tionMiddleware',
| | |
| 'django.middleware.doc.XViewMiddleware',
| | |
| )
| | |
|
| | |
| TEMPLATE_CONTEXT_PROCESSORS = ( | | TEMPLATE_CONTEXT_PROCESSORS = ( |
n | 'django.core.context_processors.auth', | n | "django.contrib.auth.context_processors.au |
| | | th", |
| 'django.core.context_processors.debug', | | "django.core.context_processors.debug", |
| 'django.core.context_processors.i18n', | | "django.core.context_processors.i18n", |
| 'django.core.context_processors.request',
| | |
| 'django.core.context_processors.media', | | "django.core.context_processors.media", |
| | | "django.core.context_processors.static",
|
| | | "django.contrib.messages.context_processor |
| | | s.messages",
|
| 'sphene.community.context_processors.navig | | 'sphene.community.context_processors.navig |
| ation', | | ation', |
| ) | | ) |
| | | |
n | # Validating template loaders
| n | ## Synchronizing tables
|
| | | |
n | Make sure you have the application template loader | n | After adding the community projects, run syncdb ag |
| in your TEMPLATE_LOADERS setting ('django.templat | | ain which will create all necessary tables.
|
| e.loaders.app_directories.load_template_source')
| | |
| | | |
n | for example:
| n | ./manage.py syncb
|
| | | |
n | TEMPLATE_LOADERS = (
| n | ## Create base template
|
| 'sphene.community.groupaware_templateloade | |
|
| r.load_template_source',
| | |
| 'django.template.loaders.filesystem.load_t | | SCT requires a template called base.html which has |
| emplate_source',
| | at least a block called "content" and one called |
| | | "head". To make this easier we will create a small |
| | | community app which hosts only your template. If |
| | | you are integrating SCT into your own project, yo |
| | | u probably already have a base template.
|
| 'django.template.loaders.app_directories.l | |
|
| oad_template_source',
| | |
| )
| | ./manage.py startapp mysitecommunity
|
| | |
|
| | | and add 'mysitecommunity' to INSTALLED_APPS in set |
| | | tings.py
|
| | |
|
| | | Now create a template directory and edit base.html |
| | |
|
| | |
|
| | | Herbys-i7:simpleproject herbert$ mkdir mysitec |
| | | ommunity/templates
|
| | | Herbys-i7:simpleproject herbert$ vi mysitecomm |
| | | unity/templates/base.html
|
| | |
|
| | | which looks like:
|
| | | |
| | | |
n | # Adding Template Directories
| n | |
|
| | |
| We need to add our template directories ..
| | |
|
| | |
| - One for your site templates which are specific t | | |
| o our new cool project
| | |
|
| | |
| Therefore edit settings.py and after setting ROOT_ | | |
| PATH = os.path.dirname(..) we created previously a | | |
| dd the following:
| | |
|
| | |
| TEMPLATE_DIRS = (
| | |
| os.path.join(ROOT_PATH,'sitetemplates'),
| | |
| )
| | |
|
| | |
| # Creating base template
| | |
|
| | |
| SCT expects to find a 'base.html' template with a | | |
| 'content' block, so we need to create a simple tem | | |
| plate. Therefore.. create the directory 'sitetempl | | |
| ates' and a file called 'base.html' with (for exam | | |
| ple) the following content:
| | |
| | | |
| <html> | | <html> |
| <head> | | <head> |
| <title>Example Project</title> | | <title>Example Project</title> |
n | | n | {% block head %}
|
| | | {% endblock %}
|
| </head> | | </head> |
| <body> | | <body> |
| {% block content %} | | {% block content %} |
| {% endblock %} | | {% endblock %} |
| </body> | | </body> |
| </html> | | </html> |
| | | |
n | For a more complete example you can look into the | n | For a more complete example you can look into the |
| [simpleproject example in the subversion repositor | | [simpleproject example in the subversion repositor |
| y](http://yourhell.com/svn/root/django/communityto | | y](https://github.com/hpoul/sct-communitytools/blo |
| ols/trunk/examples/simpleproject/sitetemplates/bas | | b/master/examples/simpleproject/sitetemplates/base |
| e.html). | | .html). |
| | | |
n | | n | ## And we are done
|
| | | |
n | # Running syncdb (again)
| n | Now start your project with ./manage.py runserver |
| | | and head over to http://127.0.0.1/board/ - You sho |
| | | uld see a very *simple* forum application.
|
| | | |
n | Since we've now finished configuration (almost) .. | n | # Community Groups
|
| . run "./manage.py syncdb" again, which will creat | | |
| e a couple of tables...
| | |
|
| | |
| # Creating example Group
| | |
| | | |
| In SCT everything is based on 'Community Groups' - | | In SCT everything is based on 'Community Groups' - |
| every forum or wiki snip is part of a 'Group' - T | | every forum or wiki snip is part of a 'Group' - T |
| his Group has nothing to do with the user groups w | | his Group has nothing to do with the user groups w |
| hich is basically only for assigning permissions - | | hich is basically only for assigning permissions - |
| a community group is more similar to the concept | | a community group is more similar to the concept |
| of the [Sites Application](http://www.djangoprojec | | of the [Sites Application](http://www.djangoprojec |
| t.com/documentation/sites/) since every community | | t.com/documentation/sites/) since every community |
| Group has one URL assigned. The main difference is | | Group has one URL assigned. The main difference is |
| tough, that Community Groups are ment to be hoste | | tough, that Community Groups are ment to be hoste |
| d on the same django instance with the same config | | d on the same django instance with the same config |
| uration, while Sites have a different configuratio | | uration, while Sites have a different configuratio |
| n for each 'Site'. | | n for each 'Site'. |
n | | n |
|
| | | When running syncdb SCT will by default create a ' |
| | | example' Community Groups which we have configured |
| | | in our urls.py to use. You can configure or creat |
| | | e more Community Groups in the Django Admin interf |
| | | ace:
|
| | | |
| Anyway .. first of all ... we need to get into the | | Anyway .. first of all ... we need to get into the |
| admin web interface.. so we need to assign an URL | | admin web interface.. so we need to assign an URL |
| : open urls.py and uncomment the following line: | | : open urls.py and uncomment the following line: |
| | | |
| (r'^admin/', include('django.contrib.admin.ur | | (r'^admin/', include('django.contrib.admin.ur |
| ls')), | | ls')), |
| | | |