Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Django's database stored web content processor

Project description


Django's database stored web content processor


My motivation to create this small package raises when I was needing to create some small pages with static URL and want to use some template tags. So, unfortunatelly Django's Flat Pages wasn't enough in my case.

Ok, so what the DeepPages does? With DeepPages you can store a page (or any other text-based content) into your database using the Page Model, set a static URL to that and get it rendered. Simple.

How it works?

DeepPages provides two ways to being used into your Django's project:

1. As Middleware

All you need is add DeepPageTemplateRendererMiddleware as a middleware in your settings. I really do recommend to insert this middleware in the end of MIDDLEWARE's list.

As Middleware

2. As PageView (TemplateView's inheritance)

Actually it was the first way that I've created. You need to include DeepPage's url patterns into your project (see Install).

As Middleware


DeepPages has three signals that you can connect to workaround. You can import those from

They are: page_requested, page_found and page_not_found.

from django.dispatch import receiver
from deeppages.signals import page_requested, page_found, page_not_found

def page_requested_callback(sender, path, request):
    # do something here

def page_not_found_callback(sender, path, request):
    # do something here

def page_found_callback(sender, path, request, page, content, context):
    # do something here

In page_found signal's receiver you can change the arguments content and context to get rendered by Middleware or PageView (depending how you've configured in your project).

Programmatically DeepPages Rendering

You can get a DeepPage rendered programmatically. To do this you just need to import get_page_by_name function from

Function statement:

def get_page_by_name(name, context=None, callback=None)


  • name = Page name
  • context (optional) = A dictionary with context for template processing
  • callback (optional) = A function to be called with arguments page and context before rendering and should return the new page content.

So, assuming that you've created a page named as test-page, do it:

from deeppages.utils import get_page_by_name

def render():
    rendered_page = get_page_by_name('test-page', ctx)
    # do something


pip install deeppages

After package install, add deeppages in your INSTALLED_APPS list.


If you want to use the Middleware way (personally, it's my preferred btw), open your settings file and look for MIDDLEWARE list.


Or, if you want to use the PageView way, you just need to open your project's URL patterns file ( and configure DeepPage as an URL Pattern:

from deeppages.views import PageView

urlpatterns = [
    url(r'^deeppages/', include(deeppages.urls, namespace='deeppages')),

This way, you can create a page with URL /test-page/ and it will be found at: /deeppages/test-page/.

Of course that you can use as default URL seeker, maybe for small projects it can work fine. For example:

urlpatterns = [
    url(r'', include(deeppages.urls, namespace='deeppages')),

Or, if you want to make your own View, you can import the PageView class and inherite from that:

from deeppages.view import PageView

class YourNewView(PageView):
    # do something

And your /test-page/ will be found at /test-page/ as well.

I'm using this package in a project that I'm developing and isn't under production environment. So, be careful to use this in production.

Feel free to make it better and send your updates/suggestions.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for deeppages, version 0.2.4
Filename, size File type Python version Upload date Hashes
Filename, size deeppages-0.2.4-py3-none-any.whl (14.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size deeppages-0.2.4.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page