【问题标题】:Changes made from the wagtail admin does not reflect on the front-end从 wagtail 管理员所做的更改不会反映在前端
【发布时间】:2019-06-26 15:51:14
【问题描述】:

wagtail 管理员所做的更改不会在前端实现。

我已经确认对 wagtail 管理员所做的更改反映在 django 管理员层。仍然在多次重新加载后,所做的更改不会反映在前端。

models.py:

class AboutUs(models.Model):
    """
    This holds the info being displayed at the '/authors' page.
    This model just stores info about the blog, it's visions and what it hopes to achieve through the internet
    """
    id = models.PositiveIntegerField(blank=True,
                                     unique=True,
                                     primary_key=True
                                     )
    title = models.CharField("Title of About Us Text",
                             max_length=100,
                             null=True,
                             blank=True,
                             help_text="Default can be named 'Default', Christmas season can be named 'Christmas'"
                             )
    about_us = RichTextField("About us",
                             null=True,
                             blank=True,
                             features=['bold', 'italic', 'hr', 'link', 'document-link', 'embed'],
                             )
    date_created = models.DateField()
    our_story = RichTextField("Our Story",
                              null=True,
                              blank=True,
                              features=['bold', 'italic', 'hr', 'link', 'document-link', 'embed'],
                              )
    our_vision = RichTextField("Our Vision",
                               null=True,
                               blank=True,
                               features=['bold', 'italic', 'hr', 'link', 'document-link', 'embed']
                               )
    our_quote = RichTextField("Our Quote",
                              null=True,
                              blank=True,
                              features=['bold', 'italic', 'hr', 'link', 'document-link', 'embed']
                              )
    author_of_quote = models.CharField("Quote Author", null=True,
                                       blank=True,
                                       max_length=100
                                       )

    panels = [
        FieldPanel('title'),
        FieldPanel('about_us'),
        FieldPanel('date_created'),
        FieldPanel('our_story'),
        FieldPanel('our_vision'),
        FieldPanel('our_quote'),
        FieldPanel('author_of_quote'),
    ]

    template = 'templates/about.html'

    def __str__(self):
        return self.title

关于.html:

    {% include "nav_and_navbars/nav_and_navbars.html" %}
        <div class="page-header">
            <div class="container">
                <div class="row">
                    <div class="col-md-offset-1 col-md-10 text-center">
                        {% if about_us %}
                        {% for inspiration in about_us %}
                        <h1> <!--class="text-uppercase"-->About <font style = "font-family:broadway regular">IXORABLOOM</font></h1>
                        <p class="lead">{{ inspiration.about_us|richtext }}</p>
                        {% endfor %}
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>
        <!-- /PAGE HEADER -->
    </header>
    <!-- /HEADER -->

    <!-- SECTION -->
    <div class="section">
        <!-- container -->
        <div class="container">
            <!-- row -->
            <div class="row">
                <div class="col-md-5">
                    <div class="section-row">
                        {% for story_base in about_us %}
                        {% if about_us %}
                        <div class="section-title">
                            <h2 class="title">Our story</h2>
                        </div>
                        <p>{{  story_base.our_story|richtext }}</p>
                        <blockquote class="blockquote">
                            <p>{{  story_base.our_quote|richtext }}</p>
                            <footer class="blockquote-footer">{{ story_base.author_of_quote }}</footer>
                        </blockquote>
                    </div>
                </div>
                <div class="col-md-7">
                    <div class="section-row">
                        <div class="section-title">
                            <h2 class="title">Our Vision</h2>
                        </div>
                        <p>{{ story_base.our_vision|richtext }}</p>
                        {% endif %}
                        {% endfor %}
                    </div>
                </div>
            </div>
            <!-- /row -->
        </div>
        <!-- /container -->
    </div>
    <!-- /SECTION -->

    {% include "footer_and_js/footer_and_js.html" %}

我希望我对 wagtail 管理员所做的文本更改会显示在前端,但在几次重新加载后,它似乎不起作用。

【问题讨论】:

    标签: django wagtail


    【解决方案1】:

    与 Django 的StateReloader 不同,它会在检测到代码库中的 [重大] 更改后自动重新启动服务器,当 wagtail 管理层发生更改时,代码库实际上没有任何更改,但是数据库已修改。由于代码库级别没有更改,因此无需重新启动或重新加载服务器。

    必须手动重新启动服务器,然后才能对前端实施更改。

    【讨论】:

    • 目前尚不清楚您正在进行哪些更改。 Django 仅在以开发模式运行时重新启动服务器(即./manage.py runserver)。 Wagtail 基于 Django 构建,因此任何 Python 代码更改都会触发重新加载。对模板的更改不会触发此操作。如果您对内容进行了任何更改,那么它们应该会显示出来,除非您有一层缓存,这在您的端口中也不清楚
    • 是的,你完全正确。经过仔细观察,我发现与wagtail admin(RichTextField)所做的更改相关的页面内容只有在我手动停止并重新启动开发服务器后才更新。如果 Django 没有自动启用缓存,那么我认为根本没有任何缓存层。所以现在,在 wagtail 管理员进行任何更改(即修改数据库)之后,我将不得不手动停止并重新启动服务器,然后重新加载页面以查看前端发生的更改
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-29
    • 2018-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-07
    相关资源
    最近更新 更多