Skip to content

Commit

Permalink
Add flatpages and ckeditor for a light cms experience
Browse files Browse the repository at this point in the history
  • Loading branch information
samihibrahim committed Sep 18, 2021
1 parent ff26917 commit 4817f63
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ html2text==2020.1.16
# Allows us to work with geojson files and perform geographic analysis
geojson==2.5.0
Shapely==1.7.1

# wysiwyg editor for flatpages
django-ckeditor==6.1.0
14 changes: 12 additions & 2 deletions website/public/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# from django.contrib import admin
from django.contrib import admin
from django.contrib.flatpages.admin import FlatPageAdmin
from django.contrib.flatpages.models import FlatPage
from django.db import models
from ckeditor.widgets import CKEditorWidget

# Register your models here.
class FlatPageCustom(FlatPageAdmin):
formfield_overrides = {
models.TextField: {'widget': CKEditorWidget}
}

admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageCustom)
9 changes: 9 additions & 0 deletions website/templates/flatpages/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends 'base.html' %}

{% block title %}
{{ flatpage.title }}
{% endblock %}

{% block content %}
{{ flatpage.content }}
{% endblock %}
2 changes: 2 additions & 0 deletions website/website/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def getenv_bool(key, default=False):
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.flatpages',
'ckeditor',
'django_extensions',
'bootstrap4',
'django_filters',
Expand Down
1 change: 1 addition & 0 deletions website/website/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# login redirects to accounts/profile on successful login
path('accounts/profile/', UserProfileView.as_view(), name='profile'),
path('admin/', admin.site.urls),
path('pages/', include('django.contrib.flatpages.urls')),
path('recipients/', include('recipients.urls')),
path('volunteers/', include('volunteers.urls')),
]

0 comments on commit 4817f63

Please sign in to comment.