S
S
SerenePawn2019-10-29 01:36:46
Django
SerenePawn, 2019-10-29 01:36:46

How to make django render templates by getting them from the database?

Templates work on ginzh. Displayed the templates themselves through {{ some_html | safe }}, it generates the page well, but here's the problem: In the template itself, I want to place one more markup for the page. That is, in this rendered thing itself there is also an attachment, a la "{{ folderol | safe }}".
Is such perversion real? Or will you have to look for workarounds?
Google didn't give me anything about it, or I just didn't find how else to ask it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan Gilfanov, 2019-10-29
@SerenePawn

This is not perversion. Batteries with WYSIWYG editors for the same Django work like this (django-ckeditor, django-tinymce, django-summernote, etc.).
Similar extensions for Flask should work in much the same way (see flask-ckeditor ). The difference is that Flask is flexible and can be prepared with different ORMs and DBMSs, so extension developers often take this into account.
But in general terms, the HTML output from the DBMS to the template looks like this:

  • in the view, you request a footcloth with HTML from the DBMS,
  • add it to the context dictionary with some key,
  • display the variable in the template with the filter | safe.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question