n | updated tutorial.
| n | |
| | | |
t | This is a simple tutorial what it needs to configu | t | |
| 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.
| | |
|
| | |
|
| | |
| # Creating a new simple Django project
| | |
|
| | |
| You should already know how to do this, it's just | | |
| a standard django setup, but i'll still walk throu | | |
| gh all steps. I am using Django 1.4 here. (Django | | |
| 1.4 has a significantly different default project | | |
| setup)
| | |
|
| | |
| ## Create a new project
| | |
|
| | |
| $ django-admin.py startproject simpleproject
| | |
|
| | |
|
| | |
| ## Configuring project to get it up and running
| | |
|
| | |
| 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 *
| | |
|
| | |
| my simpleproject/settings_local.py contains:
| | |
|
| | |
|
| | |
| 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.
| | |
| }
| | |
| }
| | |
|
| | |
| now you can run syncdb:
| | |
|
| | |
| Herbys-i7:simpleproject herbert$ ./manage.py s | | |
| yncdb
| | |
| Creating tables ...
| | |
| Creating table auth_permission
| | |
| Creating table auth_group_permissions
| | |
| Creating table auth_group
| | |
| Creating table auth_user_user_permissions
| | |
| Creating table auth_user_groups
| | |
| Creating table auth_user
| | |
| Creating table django_content_type
| | |
| Creating table django_session
| | |
| Creating table django_site
| | |
|
| | |
| You just installed Django's auth system, which | | |
| means you don't have any superusers defined.
| | |
| Would you like to create one now? (yes/no): ye | | |
| s
| | |
| Username (leave blank to use 'herbert'):
| | |
| E-mail address: a@b.com
| | |
| Password:
| | |
| Password (again):
| | |
| Superuser created successfully.
| | |
| Installing custom SQL ...
| | |
| Installing indexes ...
| | |
| Installed 0 object(s) from 0 fixture(s)
| | |
|
| | |
| Because i am on Mac OSX i got the "ValueError: unk | | |
| nown locale: UTF-8" error, so i actually ran:
| | |
|
| | |
| LC_CTYPE="en_US.UTF-8" ./manage.py syncdb
| | |
|
| | |
| 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...
| | |
|
| | |
| 0 errors found
| | |
| Django version 1.4b1, using settings 'simplepr | | |
| oject.settings'
| | |
| Development server is running at http://127.0. | | |
| 0.1:8000/
| | |
| Quit the server with CONTROL-C.
| | |
|
| | |
| I guess this was not too exciting for anyone, sinc | | |
| e you already use django, so let's go ahead!
| | |
|
| | |
| # Sphene Community Tools
| | |
|
| | |
| ## Installation
| | |
|
| | |
| First of all you have to install SCT (the communit | | |
| 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
| | |
|
| | |
| 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.
| | |
|
| | |
| ## Project Configuration
| | |
|
| | |
| Add the following applications to your INSTALLED_A | | |
| PPS:
| | |
|
| | |
| 'sphene.community',
| | |
| 'sphene.sphboard',
| | |
| 'sphene.sphwiki',
| | |
|
| | |
| ## Adding MIDDLEWARE_CLASSES and TEMPLATE_CONTEXT_ | | |
| PROCESSORS
| | |
|
| | |
|
| | |
| 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.GroupMiddlewa | | |
| re',
| | |
|
| | |
| 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:
| | |
|
| | |
|
| | |
| TEMPLATE_CONTEXT_PROCESSORS = (
| | |
| "django.contrib.auth.context_processors.au | | |
| th",
| | |
| "django.core.context_processors.debug",
| | |
| "django.core.context_processors.i18n",
| | |
| "django.core.context_processors.media",
| | |
| "django.core.context_processors.static",
| | |
| "django.contrib.messages.context_processor | | |
| s.messages",
| | |
| 'sphene.community.context_processors.navig | | |
| ation',
| | |
| )
| | |
|
| | |
| ## Synchronizing tables
| | |
|
| | |
| After adding the community projects, run syncdb ag | | |
| ain which will create all necessary tables.
| | |
|
| | |
| ./manage.py syncb
| | |
|
| | |
| ## Create base template
| | |
|
| | |
| SCT requires a template called base.html which has | | |
| 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.
| | |
|
| | |
| ./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:
| | |
|
| | |
|
| | |
|
| | |
| <html>
| | |
| <head>
| | |
| <title>Example Project</title>
| | |
| {% block head %}
| | |
| {% endblock %}
| | |
| </head>
| | |
| <body>
| | |
| {% block content %}
| | |
| {% endblock %}
| | |
| </body>
| | |
| </html>
| | |
|
| | |
| For a more complete example you can look into the | | |
| [simpleproject example in the subversion repositor | | |
| y](https://github.com/hpoul/sct-communitytools/blo | | |
| b/master/examples/simpleproject/sitetemplates/base | | |
| .html).
| | |
|
| | |
| ## And we are done
| | |
|
| | |
| 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.
| | |
|
| | |
| # Community Groups
| | |
|
| | |
| In SCT everything is based on 'Community Groups' - | | |
| every forum or wiki snip is part of a 'Group' - T | | |
| his Group has nothing to do with the user groups w | | |
| hich is basically only for assigning permissions - | | |
| a community group is more similar to the concept | | |
| of the [Sites Application](http://www.djangoprojec | | |
| t.com/documentation/sites/) since every community | | |
| Group has one URL assigned. The main difference is | | |
| tough, that Community Groups are ment to be hoste | | |
| d on the same django instance with the same config | | |
| uration, while Sites have a different configuratio | | |
| n for each 'Site'.
| | |
|
| | |
| 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 | | |
| admin web interface.. so we need to assign an URL | | |
| : open urls.py and uncomment the following line:
| | |
|
| | |
| (r'^admin/', include('django.contrib.admin.ur | | |
| ls')),
| | |
|
| | |
| Now run the project using: "./manage.py runserver" | | |
| and head over to your admin page, propably: http: | | |
| //127.0.0.1:8000/admin/
| | |
|
| | |
| There you need to login with your superuser - user | | |
| you created with the first 'syncdb' call and head | | |
| over to 'Community' -> 'Groups' (__NOT__ Auth -> | | |
| Groups) and click 'Add group'. Enter something lik | | |
| e:
| | |
|
| | |
| - Name: example
| | |
| - Longname: Example Community Group
| | |
| - Baseurl: www.example.com
| | |
|
| | |
| The only important for now is the 'name' .. i assu | | |
| me below that we have a group called 'example' whi | | |
| ch .. will be the only one we want (for now) ...
| | |
|
| | |