Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
53a81e2d
Commit
53a81e2d
authored
Oct 18, 2018
by
PJ Janse van Rensburg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant 'sqla/app2' example.
parent
f2323883
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
66 deletions
+3
-66
README.rst
examples/sqla/README.rst
+1
-2
app.py
examples/sqla/app.py
+2
-1
app2.py
examples/sqla/app2.py
+0
-63
No files found.
examples/sqla/README.rst
View file @
53a81e2d
...
...
@@ -16,10 +16,9 @@ To run this example:
pip install -r 'examples/sqla/requirements.txt'
4. Run
either of these applications
::
4. Run
the application
::
python examples/sqla/app.py
python examples/sqla/app2.py
The first time you run this example, a sample sqlite database gets populated automatically. To suppress this behaviour,
comment the following lines in app.py:::
...
...
examples/sqla/app.py
View file @
53a81e2d
...
...
@@ -100,6 +100,7 @@ def index():
# Customized User model admin
class
UserAdmin
(
sqla
.
ModelView
):
column_display_pk
=
True
column_list
=
[
'id'
,
'last_name'
,
...
...
examples/sqla/app2.py
deleted
100644 → 0
View file @
f2323883
from
flask
import
Flask
from
flask_sqlalchemy
import
SQLAlchemy
import
flask_admin
as
admin
from
flask_admin.contrib
import
sqla
# Create application
app
=
Flask
(
__name__
)
# Create dummy secrey key so we can use sessions
app
.
config
[
'SECRET_KEY'
]
=
'123456790'
# Create in-memory database
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:///sample_db_2.sqlite'
app
.
config
[
'SQLALCHEMY_ECHO'
]
=
True
db
=
SQLAlchemy
(
app
)
# Flask views
@
app
.
route
(
'/'
)
def
index
():
return
'<a href="/admin/">Click me to get to Admin!</a>'
class
Car
(
db
.
Model
):
__tablename__
=
'cars'
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
,
autoincrement
=
True
)
desc
=
db
.
Column
(
db
.
String
(
50
))
def
__str__
(
self
):
return
self
.
desc
class
Tyre
(
db
.
Model
):
__tablename__
=
'tyres'
car_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'cars.id'
),
primary_key
=
True
)
tyre_id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
car
=
db
.
relationship
(
'Car'
,
backref
=
'tyres'
)
desc
=
db
.
Column
(
db
.
String
(
50
))
class
CarAdmin
(
sqla
.
ModelView
):
column_display_pk
=
True
form_columns
=
[
'id'
,
'desc'
]
class
TyreAdmin
(
sqla
.
ModelView
):
column_display_pk
=
True
form_columns
=
[
'car'
,
'tyre_id'
,
'desc'
]
# Create admin
admin
=
admin
.
Admin
(
app
,
name
=
'Example: SQLAlchemy2'
,
template_mode
=
'bootstrap3'
)
admin
.
add_view
(
CarAdmin
(
Car
,
db
.
session
))
admin
.
add_view
(
TyreAdmin
(
Tyre
,
db
.
session
))
if
__name__
==
'__main__'
:
# Create DB
db
.
create_all
()
# Start app
app
.
run
(
debug
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment