|
UsingDjangoPhpbb
Using django-phpbb
Featured In case of django-phpbb, using it means that when you're coding a Django application, you have a set of classes and functions at your disposal, providing a “glue” between phpBB3 and Django. AuthenticationA prerequisite: Django authenticationFirst, prerequisites. Make sure your Django authentication is working. If your Django website uses authentication already, you probably have the following lines in your urls.py. (r'^accounts/login/$', 'django.contrib.auth.views.login', ),
(r'^accounts/logout/$', 'django.contrib.auth.views.logout', ),If there are no such lines in your urls.py, your application probably doesn't use authentication. Go to the Django website for instructions and get your authentication done. Adding phpbb3 authentication backendEdit your settings.py and make sure the following lines are present: MIDDLEWARE_CLASSES = (
...
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
...
"django.core.context_processors.auth",
)
INSTALLED_APPS = (
'django.contrib.auth',
...
'django.contrib.phpbb',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.phpbb.backends.PhpbbBackend',
'django.contrib.auth.backends.ModelBackend',
)Once you've done that, the authentication backend should be enabled and users should be able to log in using not only Django passwords, but also passwords checked against the phpbb3 database. phpBB3 classesYou can access phpBB3 forum objects using provided classes. Look up the source code to see the details of the classes. (Sorry for not providing any better documentation at this time.) Fire up Django shell and try using django-phpbb classes: ./manage.py shell from django.contrib.phpbb import models as p3m forum = p3m.PhpbbForum.objects.get(pk=1) dir(forum) forum.forum_name forum.phpbbtopic_set.all()[:5] Predefined viewsYou need to have a base.html template that django-phpbb's template expect to extend. To enable predefined views, add this line to your urls.py: (r'^forum/', include('django.contrib.phpbb.urls')),Also, make django-phpbb templates available: TEMPLATE_DIRS = (
...
"your-home-directory/django-trunk/django/contrib/phpbb/templates",
)The views currently contain bits and pieces of the original website they've been cut from. The views are going to be reworked. Consider them more as a guide to see how you can implement your own forum browsing rather than a complete solution. |