pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
https://flask-admin.readthedocs.io
BSD 3-Clause "New" or "Revised" License
5.73k stars 1.57k forks source link

[IDEA] How to serve static pages from flask admin with some data from db ? #1817

Open bekab95 opened 5 years ago

bekab95 commented 5 years ago

I am using mongodb and flask admin and flask admin is great ! but sometimes I have to manage some pages which have to contain not the same but different data and can not be "Modeled" in a one Model I need to find way to server semi-dynamic pages with flask and manage them with flask admin Any Ideas ?

david672orford commented 4 years ago

Let's say for example that you need to display a railway timetable. You create a model and a model view in Flask-Admin. You enter the times and the stations. Now you need to display this information in an attractive way for the public. You do not need Flask-Admin to do this, just Flask. You create regular Flask views which get the data from the database and insert it into Jinja2 templates.

bekab95 commented 4 years ago

Let's say for example that you need to display a railway timetable. You create a model and a model view in Flask-Admin. You enter the times and the stations. Now you need to display this information in an attractive way for the public. You do not need Flask-Admin to do this, just Flask. You create regular Flask views which get the data from the database and insert it into Jinja2 templates.

That is too minimal simple example, I mean some websites when there is need for models with flask when admin can insert some predefined structure data and some general pages which may require modifications in jinja only from admin for example WordPress like approach when you can mix model view logic and also have custom HTML pages built with jinja

david672orford commented 4 years ago

Maybe this is what you are looking for? https://flask-admin.readthedocs.io/en/latest/introduction/#standalone-views Note that the view is derived from BaseView, so it is not a model view. In renders a Jinja2 template which extends the admin/master.html template. This means that it will be displayed within the Flask-Admin interface.

bekab95 commented 4 years ago

Maybe this is what you are looking for? https://flask-admin.readthedocs.io/en/latest/introduction/#standalone-views Note that the view is derived from BaseView, so it is not a model view. In renders a Jinja2 template which extends the admin/master.html template. This means that it will be displayed within the Flask-Admin interface.

No No I am taking about other solution. WordPress is for administration to have some website applies to flask admin, you can add or delete some data. I am talking about the idea when you have some data which can not be in a one model for example when you need to add website menu dynamically with appropriate content and how can you do that with flask admin ? each menu item and page needs model and its HTML template and if you need to develop website when administrator needs ability to add as many and as different pages as he wish it is not possible simply, and i asked the question if there is CMS like approach with flask admin or any other python Framework

david672orford commented 4 years ago

Flask-Admin is a component, not an entire system. If you are writing your own CMS, you can use Flask-Admin for the admin part. You could create a model which stores the articles. You might then create a model view in Flask-Admin and use that to type in the articles.

You could then create a Flask view which queries to table twice: once to get the name of each article so that it can display a menu, and a second time to get the text of the particular article which it is supposed to display. The view would then feed the results of these two queries to an Jinja2 template which would render the menu and article text.

Last night I happened to find a CMS which someone is writing in Python. It uses Flask-Admin for the admin part. It is very new though and not quite finished: https://github.com/mush42/oy-cms

bekab95 commented 4 years ago

Flask-Admin is a component, not an entire system. If you are writing your own CMS, you can use Flask-Admin for the admin part. You could create a model which stores the articles. You might then create a model view in Flask-Admin and use that to type in the articles.

You could then create a Flask view which queries to table twice: once to get the name of each article so that it can display a menu, and a second time to get the text of the particular article which it is supposed to display. The view would then feed the results of these two queries to an Jinja2 template which would render the menu and article text.

Last night I happened to find a CMS which someone is writing in Python. It uses Flask-Admin for the admin part. It is very new though and not quite finished: https://github.com/mush42/oy-cms

There is not WordPress like CMS systems with python..