Configuration
DJ Press Settings
In your settings.py file, create a DJPRESS_SETTINGS dictionary to configure your blog. Here’s a basic example:
# DJPress settings
DJPRESS_SETTINGS = {
"SITE_TITLE": "My Awesome Blog",
"POST_PREFIX": "{{ year }}/{{ month }}",
}
Available Settings
Settings are grouped by functionality:
URL Structure
Setting |
Type |
Default |
Description |
|---|---|---|---|
|
str |
|
Defines URL structure for posts. Use placeholders like |
|
bool |
|
Enable/disable date-based archives. |
|
str |
|
Prefix for archive URLs. |
|
bool |
|
Enable/disable category pages. |
|
str |
|
Prefix for category URLs. |
|
bool |
|
Enable/disable tag pages. |
|
str |
|
Prefix for tag URLs. |
|
bool |
|
Enable/disable author pages. |
|
str |
|
Prefix for author URLs. |
|
bool |
|
Enable/disable RSS feed. |
|
str |
|
Path for RSS feed. |
|
bool |
|
Enable/disable search functionality. |
|
str |
|
Path for search page. |
Content Display
Setting |
Type |
Default |
Description |
|---|---|---|---|
|
str |
|
Website title used in templates. |
|
str |
|
Website description for metadata. |
|
int |
|
Number of posts displayed per page. |
|
str |
|
Text for “Read more” links. |
|
str |
|
HTML comment that marks where to truncate content. |
|
bool |
|
Enable/disable microformats in HTML. |
|
int |
|
Minimum character length for search queries. |
|
int |
|
Maximum character length for search queries. |
|
int |
|
Maximum number of tags that can be queried at once. |
Media Settings
Setting |
Type |
Default |
Description |
|---|---|---|---|
|
str |
|
Path pattern for uploaded files. |
Markdown Configuration
Setting |
Type |
Default |
Description |
|---|---|---|---|
|
list |
|
List of Python-Markdown extensions to enable. |
|
dict |
|
Configuration options for markdown extensions. |
|
str |
|
Path to markdown renderer function. |
Caching
Setting |
Type |
Default |
Description |
|---|---|---|---|
|
bool |
|
Enable/disable caching for categories. |
|
bool |
|
Enable/disable caching for tags. |
|
bool |
|
Enable/disable caching for recent posts. |
Plugin System
Setting |
Type |
Default |
Description |
|---|---|---|---|
|
list |
|
List of plugin module paths to enable. |
|
dict |
|
Configuration options for plugins. |
Theme Settings
Setting |
Type |
Default |
Description |
|---|---|---|---|
|
str |
|
Which theme to use. See the themes page for more details. |
|
dict |
|
Optional theme settings. Refer to the specific theme documentation for details. |
Example Configurations
Minimal Blog
DJPRESS_SETTINGS = {
"SITE_TITLE": "My Personal Blog",
"POST_PREFIX": "{{ year }}/{{ month }}",
"THEME": "default",
}
News Site with Categories
DJPRESS_SETTINGS = {
"SITE_TITLE": "Daily News",
"POST_PREFIX": "news",
"CATEGORY_PREFIX": "section",
"RECENT_PUBLISHED_POSTS_COUNT": 10,
"THEME": "simple",
}
Technical Documentation Site
DJPRESS_SETTINGS = {
"SITE_TITLE": "Tech Docs",
"POST_PREFIX": "articles",
"MARKDOWN_EXTENSIONS": ["codehilite", "fenced_code", "tables"],
"MARKDOWN_EXTENSION_CONFIGS": {
"codehilite": {"css_class": "highlight", "linenums": True}
},
"CACHE_RECENT_PUBLISHED_POSTS": True,
}
Themes
There are two themes included with DJ Press: “default” and “simple”. They can be configured as follows:
# DJPress settings
DJPRESS_SETTINGS = {
"THEME": "simple",
}
To create your own theme, please read the Theme documentation
Custom User Models
If your Django project uses a custom user model (AUTH_USER_MODEL), you should consider how author display names and
archive pages are generated.
Dynamic Database Settings
For most simple use-cases, configuring settings in the DJPRESS_SETTINGS object is recommended. However, DJ Press
allows you to configure settings in your database via a Setting model, which takes precedence over the file-based
settings and defaults.
This allows administrators to change settings like SITE_TITLE or SITE_DESCRIPTION directly from the Django Admin interface without needing to redeploy or modify code files.
Enabling Dynamic Database Settings
Dynamic database settings are disabled by default. To enable them, add the DATABASE_SETTINGS_ENABLED toggle to your
DJPRESS_SETTINGS dictionary in your settings.py file:
DJPRESS_SETTINGS = {
"DATABASE_SETTINGS_ENABLED": True,
}
Database Settings Precedence
When DATABASE_SETTINGS_ENABLED is True, settings are resolved in the following order of precedence:
Database settings (configured via the
Settingmodel in Django Admin).Django settings (defined in
DJPRESS_SETTINGSinsidesettings.py).App defaults (pre-defined defaults in
app_settings.py).
If a setting key does not exist in the database, DJ Press falls back to the subsequent layers. Unrecognised keys in the database are safely ignored.
Caching and Performance
To avoid executing a database query on every setting retrieval, DJ Press utilises Django’s default caching framework.
All database settings are retrieved in a single query and cached globally under the key "djpress:settings". In addition, to prevent redundant cache backend calls (network roundtrips), settings are cached in-memory for the lifetime of each HTTP request. The cache is automatically invalidated and refreshed whenever a setting is created, saved, or deleted.
[!IMPORTANT] Multi-Process Environments & Cache Requirements If your site runs on a multi-process server (such as multiple Gunicorn/uWSGI workers, or multiple containers) and you enable dynamic database settings, you must configure a shared caching backend (like Redis, Memcached, or Django’s built-in Database Cache).
If you do not configure a shared cache, Django will fall back to using
LocMemCache(local memory cache). BecauseLocMemCacheis isolated to the memory of each individual worker process, setting updates made on one worker process will not propagate to the other processes until they are restarted.
Configuring Settings in Django Admin
When configuring settings via the Django Admin interface:
Keys: Enter any setting key (e.g.
SITE_TITLE,RSS_ENABLED,RECENT_PUBLISHED_POSTS_COUNT).Values: Stored as a standard JSONField. To make this easier, the admin form uses a custom parser:
Booleans: Enter standard Python/JSON booleans (
True/true/False/false) directly without quotes.Null values: Enter
Noneornulldirectly.Text strings: Plain text strings (e.g.
My Awesome Blog) can be entered without quotes. The form field will automatically fall back to raw strings if standard JSON parsing fails.Numbers and Collections: Standard numbers (e.g.
10) or JSON collections (e.g.["markdown.extensions.tables"]or{"theme_color": "blue"}) are parsed natively into their correct types.
Validation: Any setting matching a key in
DJPRESS_SETTINGSis validated when saved to ensure that the value’s type matches the expected setting type, preventing configuration mistakes.Lockout Protection: To avoid circular conflicts, the system-level master toggle
DATABASE_SETTINGS_ENABLEDcannot be configured in the database and must be configured in the file-based settings.