If you're starting from a Django project without Wagtail integration and you want to add a blog site to your project, please follow the steps outlined under standalone_app
. If you are already using Wagtail, refer to wagtail_app
.
- Install Puput and its dependencies via
pip install puput
. - Append
PUPUT_APPS
toINSTALLED_APPS
in your settings.
from puput import PUPUT_APPS
INSTALLED_APPS += PUPUT_APPS
This includes Puput, Wagtail's apps and certain third-party dependencies. If you are already referencing one of these apps in your INSTALLED_APPS
list, please include the following apps manually in order to avoid app collisions:
INSTALLED_APPS = (
...
'wagtail.wagtailcore',
'wagtail.wagtailadmin',
'wagtail.wagtaildocs',
'wagtail.wagtailsnippets',
'wagtail.wagtailusers',
'wagtail.wagtailimages',
'wagtail.wagtailembeds',
'wagtail.wagtailsearch',
'wagtail.wagtailsites',
'wagtail.wagtailredirects',
'wagtail.wagtailforms',
'wagtail.contrib.wagtailsitemaps',
'wagtail.contrib.wagtailroutablepage',
'compressor',
'taggit',
'modelcluster',
'puput',
)
- Add Wagtail's required middleware classes to
MIDDLEWARE_CLASSES
in your Django settings.
MIDDLEWARE_CLASSES = (
...
'wagtail.wagtailcore.middleware.SiteMiddleware',
'wagtail.wagtailredirects.middleware.RedirectMiddleware',
)
- Add the
request
context processor to theTEMPLATE_CONTEXT_PROCESSORS
structure in your Django settings.
TEMPLATE_CONTEXT_PROCESSORS = (
...
'django.core.context_processors.request',
)
- Set the
WAGTAIL_SITE_NAME
variable to the name of your site in your Django settings.
WAGTAIL_SITE_NAME = 'Puput blog'
- Configure the
MEDIA_ROOT
andMEDIA_URL
settings as described in the Wagtail Docs.
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
- Place Puput's URLs at the bottom of the urlpatterns. It also includes Wagtail's URLs.
urlpatterns = [
...
url(r'', include('puput.urls')),
]
- To make your Django project serve your media files (e.g. things you upload via the admin) during development, don't forget to add this to your urlpatterns:
from django.conf import settings
if settings.DEBUG:
import os
from django.conf.urls import patterns
from django.conf.urls.static import static
from django.views.generic.base import RedirectView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns() # tell gunicorn where static files are in dev mode
urlpatterns += static(settings.MEDIA_URL + 'images/', document_root=os.path.join(settings.MEDIA_ROOT, 'images'))
urlpatterns += patterns('',
(r'^favicon\.ico$', RedirectView.as_view(url=settings.STATIC_URL + 'myapp/images/favicon.ico'))
)
- Run
python manage.py migrate
andpython manage.py puput_initial_data
to load initial data to start a blog site. - Open your browser at http://127.0.0.1:8000/blog/ to view your blog home page. Go to http://127.0.0.1:8000/blog_admin/ to view the admin site and edit your content.
- Install Puput and its dependencies via
pip install puput
. - Add
puput
,compressor
,wagtail.contrib.wagtailsitemaps
andwagtail.contrib.wagtailroutablepage
toINSTALLED_APPS
in your Django settings. - If you have previously defined Wagtail URLs in your patterns, set the
PUPUT_AS_PLUGIN
setting toTrue
. This will avoid duplicate inclusion of Wagtail's URLs when you include Puput's URLs. - Include Puput's URLs in your patterns before Wagtail's URLs.
urlpatterns = [
...
url(r'', include('puput.urls')),
url(r'', include(wagtail_urls)),
]
- Run
python manage.py migrate
.
If you want to run Puput in a Docker container please visit docker-puput for detailed instructions.