Piccolo Admin Does Not Display Too Many Columns. #381
-
I have a table, but it doesn't show any rows. Maybe it's because there are too many columns to fit because rest of my tables work fine. You can view this video to see how it looks. We need a scroll bar so we can see all the columns, but I'm not sure if it's already there and this is just a UI bug because I did not check the source code. Here's the table: import os
from piccolo.columns.column_types import (
Date,
Serial,
Varchar,
)
from piccolo.table import Table
from piccolo_admin.endpoints import TableConfig
from piccolo_api.media.local import LocalMediaStorage
from utils.helpers import get_url
from .enums import Class, Stream, Subject, UploadType
class Upload(Table, tablename="uploads"):
id: Serial
title = Varchar(required=True, null=False)
created_at = Date(required=True, null=False)
type_ = Varchar(choices=UploadType, required=True, null=False, db_column_name="type")
file = Varchar(required=True, null=False)
class_ = Varchar(choices=Class, required=True, null=False, db_column_name="class")
subject = Varchar(choices=Subject, required=False, null=True)
stream = Varchar(choices=Stream, required=False, null=True)
def to_dict(self) -> dict:
return {
"id": self.id,
"title": self.title,
"created_at": self.created_at,
"type": self.type_,
"file": get_url(f"/uploads/{self.file}"),
"class": self.class_,
"subject": self.subject,
"stream": self.stream,
}
UPLOAD_FILES_MEDIA = LocalMediaStorage(
column=Upload.file,
media_path=os.path.join(os.environ["MEDIA_ROOT"], "uploads"),
allowed_extensions=[
"jpg",
"jpeg",
"png",
"pdf",
],
)
UPLOADS_CONFIG = TableConfig(
Upload,
visible_columns=[
Upload.id,
Upload.title,
Upload.created_at,
Upload.type_,
Upload.file,
Upload.class_,
Upload.subject,
Upload.stream,
],
visible_filters=[
Upload.title,
Upload.created_at,
Upload.type_,
Upload.file,
Upload.class_,
Upload.subject,
Upload.stream,
],
media_storage=[UPLOAD_FILES_MEDIA],
) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Are there any errors in the web console, or terminal? |
Beta Was this translation helpful? Give feedback.
-
@amazingakai The problem is the |
Beta Was this translation helpful? Give feedback.
@amazingakai The problem is the
type_
andclass_
columns because thecolumn._meta.name
is not the same as thecolumn._meta.db_column_name
. For now, if you just remove thedb_column_name
from the column definition, everything works fine. I'll take a closer look tomorrow.