Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: invalid literal for int() with base 10: '6, 2' #40

Open
ShahriyarR opened this issue May 22, 2021 · 1 comment
Open

ValueError: invalid literal for int() with base 10: '6, 2' #40

ShahriyarR opened this issue May 22, 2021 · 1 comment

Comments

@ShahriyarR
Copy link

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'
@xnuinside
Copy link
Owner

@ShahriyarR, thanks for the report, I will try to fix as soon as possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants