question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Saving page in admin GUI sets template to empty

See original GitHub issue

I think this bug only exists on master (no release yet). I’m creating this issue to ensure that we don’t release a new version until it’s fixed. Alternatively we have to establish that the cause is not something else on my system 😅

I installed Lektor like this (probably not related):

# Install lektor
pip3 install --user git+https://github.com/lektor/lektor

# Generate JS files for admin
cd ~/.local/lib/python3.7/site-packages/lektor/admin/
npm install
npm run webpack

# Create a new project and start admin GUI
lektor quickstart
cd <your-project>
lektor server

Open the admin GUI and edit the home page and click save (no need to make any changes).

You should see the following error:

Traceback (most recent call last):
  File "/home/$USER/.local/lib/python3.7/site-packages/lektor/builder.py", line 800, in update
    yield ctx
  File "/home/$USER/.local/lib/python3.7/site-packages/lektor/builder.py", line 1070, in build_artifact
    build_func(artifact)
  File "/home/$USER/.local/lib/python3.7/site-packages/lektor/build_programs.py", line 183, in build_artifact
    self.source['_template'], this=self.source)
  File "/home/$USER/.local/lib/python3.7/site-packages/lektor/builder.py", line 655, in render_template_into
    this=this, **extra)
  File "/home/$USER/.local/lib/python3.7/site-packages/lektor/environment.py", line 542, in render_template
    return self.jinja_env.get_or_select_template(name).render(ctx)
  File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 869, in get_or_select_template
    return self.get_template(template_name_or_list, parent, globals)
  File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 830, in get_template
    return self._load_template(name, self.make_globals(globals))
  File "/home/$USER/.local/lib/python3.7/site-packages/lektor/environment.py", line 217, in _load_template
    rv = jinja2.Environment._load_template(self, name, globals)
  File "/usr/lib/python3.7/site-packages/jinja2/environment.py", line 804, in _load_template
    template = self.loader.load(self, name, globals)
  File "/usr/lib/python3.7/site-packages/jinja2/loaders.py", line 113, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "/usr/lib/python3.7/site-packages/jinja2/loaders.py", line 187, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound

If I look into the contents.lr file I can see that Lektor has saved some system fields and set their values to empty:

title: Welcome to asdf!
---
body:

This is a basic demo website that shows how to use Lektor for a basic
website with some pages and a blog.
---
_discoverable: 
---
_hidden: 
---
_slug: 
---
_template: 

In previous versions Lektor has never saved these fields (_discoverable, _hidden, _slug and _template) unless they have an explicitly defined value. I suspect this is caused by one of the PRs related to admin form handling: #660, #667, #670 or #679. I’ll try to bisect this issue later.

Environment

  • Python 3.7
  • Firefox 69
  • Fedora 30
  • npm 6.9.0
  • node js 10.16.3

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
runfalkcommented, Oct 10, 2019

Sure, that will probably fix it. I think we might even be able to go as far as filtering out all empty fields.

However, I’d like to find out how and why this happened first before fixing it this way though.

0reactions
yagebucommented, Mar 4, 2020

I managed to bisect this to the commit 11e94e1720f1cad1844967ccdd77b92b11839527. I’ll open a PR reverting that commit but will try to port the performance optimization.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage list templates - Microsoft Support
Open the list that you want to save as a template. Select Settings, and then select List Settings. In the Permissions and Management...
Read more >
Django Admin change page: How can I put the save button set ...
Currently, I have the default setting.
Read more >
Create a template by saving a form - ServiceNow Docs
Navigate to a form. · Complete the form as it should appear when a user applies the template. · In the template bar,...
Read more >
The Django admin site
In this document we discuss how to activate, use, and customize Django's admin interface. Overview¶. The admin is enabled in the default project...
Read more >
Customize the Django Admin With Python
You'll also use template overriding to gain full control over the admin's HTML. ... You can use it out of the box to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found