Skip to content

Commit

Permalink
added wagtail
Browse files Browse the repository at this point in the history
  • Loading branch information
qtrinh2 committed Nov 20, 2024
1 parent 5a426e0 commit 7dc9b73
Show file tree
Hide file tree
Showing 13 changed files with 711 additions and 3 deletions.
23 changes: 22 additions & 1 deletion django/django_test/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,26 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail',

'modelcluster',
'taggit',

'tailwind',
'theme',

'home',
'sample',
'upload',
]
Expand All @@ -60,6 +78,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'wagtail.contrib.redirects.middleware.RedirectMiddleware',
]

ROOT_URLCONF = 'django_test.urls'
Expand Down Expand Up @@ -170,7 +189,9 @@
MEDIA_URL = "media/"
MEDIA_ROOT = os.path.join(BASE_DIR, 'mediafiles')


# Wagtail
WAGTAIL_SITE_NAME = 'My Wagtail Site'
WAGTAILADMIN_BASE_URL = 'http://localhost:8000'

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
Expand Down
9 changes: 8 additions & 1 deletion django/django_test/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,22 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path
from django.urls import path, include

from . import views
from upload.views import image_upload
from sample.views import root

from wagtail.admin import urls as wagtailadmin_urls
from wagtail import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls

urlpatterns = [
path('', views.index, name='index'),
path('admin/', admin.site.urls),
path('wagtail-admin/', include(wagtailadmin_urls)),
path('wagtail/', include(wagtail_urls)),
path('documents/', include(wagtaildocs_urls)),
path('sample/', root, name='sample'),
path('upload/', image_upload, name='upload'),
]
Expand Down
Empty file added django/home/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions django/home/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions django/home/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class HomeConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'home'
28 changes: 28 additions & 0 deletions django/home/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.1.3 on 2024-11-20 21:20

import django.db.models.deletion
import wagtail.fields
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
('wagtailcore', '0094_alter_page_locale'),
]

operations = [
migrations.CreateModel(
name='HomePage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('body', wagtail.fields.RichTextField(blank=True)),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]
Empty file.
11 changes: 11 additions & 0 deletions django/home/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.db import models
from wagtail.models import Page
from wagtail.fields import RichTextField
from wagtail.admin.panels import FieldPanel

class HomePage(Page):
body = RichTextField(blank=True)

content_panels = Page.content_panels + [
FieldPanel('body'),
]
3 changes: 3 additions & 0 deletions django/home/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions django/home/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
618 changes: 617 additions & 1 deletion django/poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions django/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ boto3 = "^1.34.137"
django-storages = "^1.14.3"
daphne = "^4.1.2"
whitenoise = "^6.8.2"
wagtail = "^6.3.1"


[build-system]
Expand Down
9 changes: 9 additions & 0 deletions django/templates/home/home_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- load wagtailcore_tags by adding this: -->
{% load wagtailcore_tags %}

{% block body_class %}template-homepage{% endblock %}

<!-- replace everything below with: -->
{% block content %}
{{ page.body|richtext }}
{% endblock %}

0 comments on commit 7dc9b73

Please sign in to comment.