'polymorphic_identity': 'candle',
'inherit_condition': (id == Product.id)
}
class AdministratorView(ModelView):
can_create = True
can_delete = True
can_edit = True
column_display_pk = True
def is_accessible(self):
#TODO
return True #current_user.is_authenticated and current_user.has_role("Administrateur")
def inaccessible_callback(self, name, **kwargs):
# redirect to login page if user doesn't have access
return redirect(url_for('security.login', next=request.url))
class ProductView(AdministratorView):
column_display_pk = True
column_labels = {'id':'Référence',
'name':'Désignation',
'image':'Image',
'availability':'Disponibilité',
'price':'Prix de vente',
'description':'Description du produit',
'type':'Type de produit',
'collections':'Collections'}
form_columns = ('id', 'name', 'image', 'availability', 'price', 'description', 'type')
# HERE'S THE PROBLEMATIC INSTRUCTION
inline_models = (Candle,)
admin.add_view(ProductView(Product, db.session, name='All', category='Products'))
# if i let AdministratorView, it works, but not as i want.
admin.add_view(AdministratorView(Candle, db.session, name='Candlery', category='Products'))
Could you tell me why, please ?
Edit 1 Formatting
Edit 2 Solved : in fact, after fiddling with the forms, i realised i took the problem backwards :
The Candle ModelView form manages the inheritance and does the right thing : inserting its Product part in Product, and its Candle part in Candle. No need to first create a Product, then linking a Candle to it.
I'll let this post here. In case someone, someday has the same twisted mind problem.
/r/flask
https://redd.it/6msraw
'inherit_condition': (id == Product.id)
}
class AdministratorView(ModelView):
can_create = True
can_delete = True
can_edit = True
column_display_pk = True
def is_accessible(self):
#TODO
return True #current_user.is_authenticated and current_user.has_role("Administrateur")
def inaccessible_callback(self, name, **kwargs):
# redirect to login page if user doesn't have access
return redirect(url_for('security.login', next=request.url))
class ProductView(AdministratorView):
column_display_pk = True
column_labels = {'id':'Référence',
'name':'Désignation',
'image':'Image',
'availability':'Disponibilité',
'price':'Prix de vente',
'description':'Description du produit',
'type':'Type de produit',
'collections':'Collections'}
form_columns = ('id', 'name', 'image', 'availability', 'price', 'description', 'type')
# HERE'S THE PROBLEMATIC INSTRUCTION
inline_models = (Candle,)
admin.add_view(ProductView(Product, db.session, name='All', category='Products'))
# if i let AdministratorView, it works, but not as i want.
admin.add_view(AdministratorView(Candle, db.session, name='Candlery', category='Products'))
Could you tell me why, please ?
Edit 1 Formatting
Edit 2 Solved : in fact, after fiddling with the forms, i realised i took the problem backwards :
The Candle ModelView form manages the inheritance and does the right thing : inserting its Product part in Product, and its Candle part in Candle. No need to first create a Product, then linking a Candle to it.
I'll let this post here. In case someone, someday has the same twisted mind problem.
/r/flask
https://redd.it/6msraw
reddit
[AF Flask-SQLAlchemy / Flask-Admin] Problem with... • r/flask
Hi gals & guys. 3 days i'm stuck with a problem with Flask_admin. I think i'll need something stronger than a stack of online doc and a rubber...
init() takes 1 positional argument but 3 were given
Someone Help please I don't know why my code is running on Juptyer
\# DASH Framework for Jupyter
from jupyter_dash import JupyterDash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output
from pymongo import MongoClient
from bson.json_util import dumps
\# URL Lib to make sure that our input is 'sane'
import urllib.parse
\#TODO: import for your CRUD module
from aac_crud import AnimalShelter
\# Build App
app = JupyterDash("ModuleFive")
app.layout = html.Div([
\# This element generates an HTML Heading with your name
html.H1("Module 5 Asssignment - Stephanie Spraglin"),
\# This Input statement sets up an Input field for the username.
dcc.Input(
id="input_user".format("text"),
type="text",
placeholder="input type {}".format("text")),
\# This Input statement sets up an Input field for the password.
\# This designation masks the user input on the screen.
dcc.Input(
id="input_passwd".format("password"),
type="password",
placeholder="input type {}".format("password")),
\# Create a button labeled 'Submit'. When the button is pressed
\# the n_clicks value will increment by 1.
html.Button('Submit', id='submit-val', n_clicks=0),
\# Generate a horizontal line separating our input from our
\# output element
html.Hr(),
\# This sets up the output element for the dashboard. The
\# purpose of the stlye option is to make sure that the
\# output will function like a regular text area and accept
\# newline ('\\n') characters as line-breaks.
html.Div(id="query-out", style={'whiteSpace': 'pre-line'}),
\#TODO: insert unique identifier code here. Please Note:
\# when you insert another HTML element here, you will need to
\# add a comma to
/r/flask
https://redd.it/1ijja7g
Someone Help please I don't know why my code is running on Juptyer
\# DASH Framework for Jupyter
from jupyter_dash import JupyterDash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output
from pymongo import MongoClient
from bson.json_util import dumps
\# URL Lib to make sure that our input is 'sane'
import urllib.parse
\#TODO: import for your CRUD module
from aac_crud import AnimalShelter
\# Build App
app = JupyterDash("ModuleFive")
app.layout = html.Div([
\# This element generates an HTML Heading with your name
html.H1("Module 5 Asssignment - Stephanie Spraglin"),
\# This Input statement sets up an Input field for the username.
dcc.Input(
id="input_user".format("text"),
type="text",
placeholder="input type {}".format("text")),
\# This Input statement sets up an Input field for the password.
\# This designation masks the user input on the screen.
dcc.Input(
id="input_passwd".format("password"),
type="password",
placeholder="input type {}".format("password")),
\# Create a button labeled 'Submit'. When the button is pressed
\# the n_clicks value will increment by 1.
html.Button('Submit', id='submit-val', n_clicks=0),
\# Generate a horizontal line separating our input from our
\# output element
html.Hr(),
\# This sets up the output element for the dashboard. The
\# purpose of the stlye option is to make sure that the
\# output will function like a regular text area and accept
\# newline ('\\n') characters as line-breaks.
html.Div(id="query-out", style={'whiteSpace': 'pre-line'}),
\#TODO: insert unique identifier code here. Please Note:
\# when you insert another HTML element here, you will need to
\# add a comma to
/r/flask
https://redd.it/1ijja7g
Reddit
From the flask community on Reddit
Explore this post and more from the flask community