xnuinside / gino-admin Goto Github PK
View Code? Open in Web Editor NEWAdmin Panel for GinoORM - ready to up & run (just add your models)
Home Page: https://gino-admin.readthedocs.io/en/latest/
License: MIT License
Admin Panel for GinoORM - ready to up & run (just add your models)
Home Page: https://gino-admin.readthedocs.io/en/latest/
License: MIT License
How can I customize the edit page? Id field available for editing, no default values for fields.
Lib version: 0.2.5
Simple model:
class User(db.Model):
__tablename__ = 'users'
pk = Column(db.String(), primary_key=True, unique=True)
telegram_id = Column(Integer())
nickname = Column(String(length=33), default='-')
def __str__(self):
return f'{self.nickname} - {self.telegram_id}'
If in the models you define Numeric type with precision and scale:
class Product(db.Model):
__tablename__ = 'product'
id = db.Column(db.BigInteger(), primary_key=True)
category = db.Column(db.BigInteger(), db.ForeignKey('category.id'))
name = db.Column(db.String(), unique=True, nullable=False)
slug = db.Column(db.String(), unique=True, nullable=False)
description = db.Column(db.Unicode(), nullable=True)
price = db.Column(db.Numeric(6, 2), nullable=False)
image = db.Column(db.String(), nullable=True)
thumbnail = db.Column(db.String(), nullable=True)
date_added = db.Column(db.DateTime(), nullable=False)
We will get:
Traceback (most recent call last):
File "/home/shako/REPOS/Learning_FastAPI/Djackets/backend/app/admin.py", line 17, in <module>
create_admin_app(
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 185, in create_admin_app
return init_admin_app(host, port, db, db_models, config)
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 196, in init_admin_app
add_admin_panel(app, db, db_models, **config)
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 129, in add_admin_panel
extract_models_metadata(db, db_models)
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 97, in extract_models_metadata
column_details = extract_column_data(model_id)
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/core.py", line 45, in extract_column_data
len_ = int(str(column.type).split("(")[1].split(")")[0])
ValueError: invalid literal for int() with base 10: '6, 2'
I hit an jina2 parsing issue when using gino-admin.
For information, my db is PostgreSQL.
When going on one of model page or gino_admin_users, I get the following error:
jinja2.exceptions.TemplateAssertionError: no test named 'boolean'
I did find a few similar issues on different libraries but no solutions so far, do you have an idea how to solve this ?
See trace bellow:
Traceback (most recent call last):
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/sanic/app.py", line 939, in handle_request
response = await response
File "/usr/local/lib/python3.7/site-packages/gino_admin/auth.py", line 37, in validate
return await route(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/gino_admin/routes/crud.py", line 25, in model_view_table
return await render_model_view(request, model_id)
File "/usr/local/lib/python3.7/site-packages/gino_admin/routes/logic.py", line 60, in render_model_view
unique=cfg.models[model_id]["identity"],
File "/usr/local/lib/python3.7/site-packages/gino_admin/config.py", line 36, in render_with_updated_context
self.render_string(template, request, **context),
File "/usr/local/lib/python3.7/site-packages/sanic_jinja2/__init__.py", line 141, in render_string
return self.env.get_template(template).render(**context)
File "/usr/local/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/gino_admin/templates/data_table.html", line 23, in template
{% if field is boolean %}
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 1005, in render
return concat(self.root_render_func(self.new_context(vars)))
File "/usr/local/lib/python3.7/site-packages/gino_admin/templates/model_view.html", line 14, in root
</div>
File "/usr/local/lib/python3.7/site-packages/gino_admin/templates/base.html", line 14, in root
File "/usr/local/lib/python3.7/site-packages/gino_admin/templates/app.html", line 22, in root
<script src="https://cdn.rawgit.com/mdehoog/Semantic-UI/6e6d051d47b598ebab05857545f242caf2b4b48c/dist/semantic.min.js"></script>
File "/usr/local/lib/python3.7/site-packages/gino_admin/templates/base.html", line 31, in block_content
File "/usr/local/lib/python3.7/site-packages/gino_admin/templates/model_view.html", line 41, in block_body
<div class="eight wide column left aligned content" id="grid_footer_left"><br>
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 830, in get_template
return self._load_template(name, self.make_globals(globals))
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "/usr/local/lib/python3.7/site-packages/jinja2/loaders.py", line 125, in load
code = environment.compile(source, name, filename)
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 591, in compile
self.handle_exception(exc_info, source_hint=source_hint)
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.7/site-packages/gino_admin/templates/data_table.html", line 23, in template
{% if field is boolean %}
File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 543, in _generate
optimized=self.optimized)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 82, in generate
generator.visit(node)
File "/usr/local/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 754, in visit_Template
self.blockvisit(node.body, frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 378, in blockvisit
self.visit(node, frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 1122, in visit_For
self.blockvisit(node.body, loop_frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 378, in blockvisit
self.visit(node, frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 1122, in visit_For
self.blockvisit(node.body, loop_frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 378, in blockvisit
self.visit(node, frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 1160, in visit_If
self.blockvisit(node.body, if_frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 378, in blockvisit
self.visit(node, frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 1157, in visit_If
self.visit(node.test, if_frame)
File "/usr/local/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 70, in new_func
return f(self, node, frame, **kwargs)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 1607, in visit_Test
self.fail('no test named %r' % node.name, node.lineno)
File "/usr/local/lib/python3.7/site-packages/jinja2/compiler.py", line 315, in fail
raise TemplateAssertionError(msg, lineno, self.name, self.filename)
Hi! If you read this ticket, you know JS, HTML & css, and you want to get some practice - your welcome. UI has a lot of issues and need help to fix them.
Hey there! This is shaping up to be super useful for me. Thanks for your hard work!
I tried to add this to my Sanic app and then to start it up with uvloop. It gives me an error because gino_admin.core.add_admin_panel
tries to run it's own asyncio loop. I noticed that the function that it calls doesn't seem to have any async components. Would you accept a patch to remove the asyncio call and change gino_admin.users.add_users_model
to a synchronous function?
Logic:
Copy chosen element and all data that depend on it in chain.
For example,
exist table user
exist table restaurants
exist table dishes
exist table drinks
user.id ForeignKey for Place as owner_id
user (one) to (many) Places
Place (one) to (many) dishes & drinks
So when we do 'Deepcopy' of 'user'
We copy all his Places, with all dishes and drinks that chained to Place
I got this error when I tried to open the model in the admin panel
File "..../venv/lib/python3.8/site-packages/gino_admin/utils.py", line 304, in get_obj_id_from_row
result[x] = row[x].isoformat()
AttributeError: 'NoneType' object has no attribute 'isoformat'
class Notification(db.Model):
......
created_at = db.Column(
sa.DateTime,
nullable=False,
server_default=sa.func.now(),
)
read_at = db.Column(sa.DateTime, nullable=True)
The error occurs for the read_at field, since it can be None
gino-admin/gino_admin/utils.py
Line 304 in 1789d63
Got the following error while trying to delete data:
[2021-05-24 20:16:18 +0400] - (sanic.access)[INFO][127.0.0.1:45260]: GET http://0.0.0.0:5000/admin/category/ 200 15340
[2021-05-24 20:16:24 +0400] [29850] [DEBUG] KeepAlive Timeout. Closing connection.
[2021-05-24 20:16:42 +0400] [29850] [ERROR] Exception occurred while handling uri: 'http://0.0.0.0:5000/admin/category/delete/'
Traceback (most recent call last):
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/sanic/app.py", line 724, in handle_request
response = await response
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/auth.py", line 37, in validate
return await route(request, *args, **kwargs)
File "/home/shako/REPOS/Learning_FastAPI/Djackets/.venv/lib/python3.9/site-packages/gino_admin/routes/crud.py", line 146, in model_delete
return await model_view_table(request, model_id, flash_message)
TypeError: 'tuple' object is not callable
[2021-05-24 20:16:42 +0400] - (sanic.access)[INFO][127.0.0.1:45296]: POST http://0.0.0.0:5000/admin/category/delete/ 500 1837
[2021-05-24 20:16:42 +0400] - (sanic.access)[INFO][127.0.0.1:45296]: GET http://0.0.0.0:5000/favicon.ico 404 673
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.