Configuration


From a project two files have to be modified to use django-neon: settings.py and urls.py. Also it's good practice to use a project-wide template-directory.

myproject/
    manage.py
    myproject/
        __init__.py
        settings.py
        urls.py
        wsgi.py
    django_neon/
    templates/

Settings


Configuring the settings.py file.

Installed Applications

django-neon has to be added to the INSTALLED_APPS list:

INSTALLED_APPS = [
    ...
    'django_neon',
]

Templates

In order to find templates at the project-wide directory add the path to the DIRS list used by django for template loading:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
    ...

django-neon specific template settings

These settings can be added to the and of the settings.py file.

Every page have to use a template for rendering. Files listed in NEON_TEMPLATE_NAMES are listed as options for pages in the django-admin backend and searched from django in the templates directory first.

# django-neon settings:
NEON_TEMPLATE_NAMES = [
    'standard.html',
]

Warning: in NEON_TEMPLATE_NAMES listed files must exist and have to be found by the django template-loader. Otherwise the application will raise a 500 Error.

The setting of NEON_404_TEMPLATE_NAME is optional. By default django-neon searches for a template 404.html in case a page is not found. One can change this here.

# optional: '404.html' is default
NEON_404_TEMPLATE_NAME = '404.html'

URLS


Configuring the urls.py file.

After creating a new project a fresh urls.py file looks like that:

from django.conf.urls import url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
]

To deliver pages from django-neon the django_neon.urls file has to be included:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^page/', include('django_neon.urls')),
]

In this case every url starting with 'page' will get handled by the django-neon application. Instead of 'page' other prefixes will work as well.

Info: The django-neon-url itself starts with a number followed by a string. The number is the id of the page which is used for database-lookup. The string is the slug from the title. This slug is only there for scanning search engines; internally the slug is discarded and unused.

To serve also the homepage from django-neon the corresponding view has to be used and configured:

from django.conf.urls import include, url
from django.contrib import admin
from django_neon.views import HomePageView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^page/', include('django_neon.urls')),
    url(r'^$',
        HomePageView.as_view(),
        name='neonhome'),
]

Here the view-class HomePageView has been imported from django_neon.views serving requests for the domain without a tailing path. From a django-template this url can get by {% url 'neonhome' %} (which is in this case the same as '/').